EVOLUTION-MANAGER
Edit File: api.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>API Documentation — python-fedora 0.10.0 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '', VERSION: '0.10.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within python-fedora 0.10.0 documentation" href="_static/opensearch.xml"/> <link rel="top" title="python-fedora 0.10.0 documentation" href="index.html" /> <link rel="next" title="Glossary" href="glossary.html" /> <link rel="prev" title="JavaScript" href="javascript.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="glossary.html" title="Glossary" accesskey="N">next</a> |</li> <li class="right" > <a href="javascript.html" title="JavaScript" accesskey="P">previous</a> |</li> <li><a href="index.html">python-fedora 0.10.0 documentation</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="api-documentation"> <h1>API Documentation<a class="headerlink" href="#api-documentation" title="Permalink to this headline">¶</a></h1> <p>This API Documentation is currently a catch-all. We’re going to merge the API docs into the hand created docs as we have time to integrate them.</p> <div class="toctree-wrapper compound"> <ul class="simple"> </ul> </div> <div class="section" id="module-fedora.client"> <span id="client"></span><h2>Client<a class="headerlink" href="#module-fedora.client" title="Permalink to this headline">¶</a></h2> <p>fedora.client is used to interact with Fedora Services.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 0.3.21: </span>Deprecate DictContainer in favor of bunch.Bunch</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 0.3.35: </span>Add the openid clients</p> <p><em>Module author: Ricky Zhou <<a class="reference external" href="mailto:ricky%40fedoraproject.org">ricky<span>@</span>fedoraproject<span>.</span>org</a>></em></p> <p><em>Module author: Luke Macken <<a class="reference external" href="mailto:lmacken%40redhat.com">lmacken<span>@</span>redhat<span>.</span>com</a>></em></p> <p><em>Module author: Toshio Kuratomi <<a class="reference external" href="mailto:tkuratom%40redhat.com">tkuratom<span>@</span>redhat<span>.</span>com</a>></em></p> <dl class="exception"> <dt id="fedora.client.FedoraServiceError"> <em class="property">exception </em><tt class="descclassname">fedora.client.</tt><tt class="descname">FedoraServiceError</tt><a class="headerlink" href="#fedora.client.FedoraServiceError" title="Permalink to this definition">¶</a></dt> <dd><p>Base Exception for any problem talking with the Service.</p> <p>When the Client gets an error talking to the server, an exception of this type is raised. This can be anything in the networking layer up to an error returned from the server itself.</p> </dd></dl> <dl class="exception"> <dt id="fedora.client.ServerError"> <em class="property">exception </em><tt class="descclassname">fedora.client.</tt><tt class="descname">ServerError</tt><big>(</big><em>url</em>, <em>status</em>, <em>msg</em><big>)</big><a class="headerlink" href="#fedora.client.ServerError" title="Permalink to this definition">¶</a></dt> <dd><p>Unable to talk to the server properly.</p> <p>This includes network errors and 500 response codes. If the error was generated from an http response, <tt class="xref py py-attr docutils literal"><span class="pre">code</span></tt> is the HTTP response code. Otherwise, <tt class="xref py py-attr docutils literal"><span class="pre">code</span></tt> will be -1.</p> </dd></dl> <dl class="exception"> <dt id="fedora.client.AuthError"> <em class="property">exception </em><tt class="descclassname">fedora.client.</tt><tt class="descname">AuthError</tt><a class="headerlink" href="#fedora.client.AuthError" title="Permalink to this definition">¶</a></dt> <dd><p>Error during authentication. For instance, invalid password.</p> </dd></dl> <dl class="exception"> <dt id="fedora.client.AppError"> <em class="property">exception </em><tt class="descclassname">fedora.client.</tt><tt class="descname">AppError</tt><big>(</big><em>name</em>, <em>message</em>, <em>extras=None</em><big>)</big><a class="headerlink" href="#fedora.client.AppError" title="Permalink to this definition">¶</a></dt> <dd><p>Error condition that the server is passing back to the client.</p> </dd></dl> <dl class="exception"> <dt id="fedora.client.FedoraClientError"> <em class="property">exception </em><tt class="descclassname">fedora.client.</tt><tt class="descname">FedoraClientError</tt><a class="headerlink" href="#fedora.client.FedoraClientError" title="Permalink to this definition">¶</a></dt> <dd><p>Base Exception for problems which originate within the Clients.</p> <p>This should be the base class for any exceptions that the Client generates generate. For instance, if the client performs validation before passing the data on to the Fedora Service.</p> <p>Problems returned while talking to the Services should be returned via a <cite>FedoraServiceError</cite> instead.</p> </dd></dl> <dl class="exception"> <dt id="fedora.client.FASError"> <em class="property">exception </em><tt class="descclassname">fedora.client.</tt><tt class="descname">FASError</tt><a class="headerlink" href="#fedora.client.FASError" title="Permalink to this definition">¶</a></dt> <dd><p>FAS Error</p> </dd></dl> <dl class="exception"> <dt id="fedora.client.CLAError"> <em class="property">exception </em><tt class="descclassname">fedora.client.</tt><tt class="descname">CLAError</tt><a class="headerlink" href="#fedora.client.CLAError" title="Permalink to this definition">¶</a></dt> <dd><p>CLA Error</p> </dd></dl> <div class="section" id="generic-clients"> <h3>Generic Clients<a class="headerlink" href="#generic-clients" title="Permalink to this headline">¶</a></h3> <div class="section" id="baseclient"> <h4>BaseClient<a class="headerlink" href="#baseclient" title="Permalink to this headline">¶</a></h4> <dl class="class"> <dt id="fedora.client.BaseClient"> <em class="property">class </em><tt class="descclassname">fedora.client.</tt><tt class="descname">BaseClient</tt><big>(</big><em>base_url</em>, <em>useragent=None</em>, <em>debug=False</em>, <em>insecure=False</em>, <em>username=None</em>, <em>password=None</em>, <em>httpauth=None</em>, <em>session_cookie=None</em>, <em>session_id=None</em>, <em>session_name='tg-visit'</em>, <em>cache_session=True</em>, <em>retries=None</em>, <em>timeout=None</em><big>)</big><a class="headerlink" href="#fedora.client.BaseClient" title="Permalink to this definition">¶</a></dt> <dd><p>A client for interacting with web services.</p> <dl class="method"> <dt id="fedora.client.BaseClient.logout"> <tt class="descname">logout</tt><big>(</big><big>)</big><a class="headerlink" href="#fedora.client.BaseClient.logout" title="Permalink to this definition">¶</a></dt> <dd><p>Logout from the server.</p> </dd></dl> <dl class="method"> <dt id="fedora.client.BaseClient.send_request"> <tt class="descname">send_request</tt><big>(</big><em>method</em>, <em>req_params=None</em>, <em>file_params=None</em>, <em>auth=False</em>, <em>retries=None</em>, <em>timeout=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#fedora.client.BaseClient.send_request" title="Permalink to this definition">¶</a></dt> <dd><p>Make an HTTP request to a server method.</p> <p>The given method is called with any parameters set in req_params. If auth is True, then the request is made with an authenticated session cookie.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> <li><strong>method</strong> – Method to call on the server. It’s a url fragment that comes after the base_url set in __init__().</li> <li><strong>req_params</strong> – Extra parameters to send to the server.</li> <li><strong>file_params</strong> – dict of files where the key is the name of the file field used in the remote method and the value is the local path of the file to be uploaded. If you want to pass multiple files to a single file field, pass the paths as a list of paths.</li> <li><strong>auth</strong> – If True perform auth to the server, else do not.</li> <li><strong>retries</strong> – if we get an unknown or possibly transient error from the server, retry this many times. Setting this to a negative number makes it try forever. Default to use the <tt class="xref py py-attr docutils literal"><span class="pre">retries</span></tt> value set on the instance or in <tt class="xref py py-meth docutils literal"><span class="pre">__init__()</span></tt> (which defaults to zero, no retries).</li> <li><strong>timeout</strong> – A float describing the timeout of the connection. The timeout only affects the connection process itself, not the downloading of the response body. Default to use the <tt class="xref py py-attr docutils literal"><span class="pre">timeout</span></tt> value set on the instance or in <tt class="xref py py-meth docutils literal"><span class="pre">__init__()</span></tt> (which defaults to 120s).</li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">Bunch</p> </td> </tr> <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">The data from the server</p> </td> </tr> </tbody> </table> <p class="versionchanged"> <span class="versionmodified">Changed in version 0.3.21: </span>* Return data as a Bunch instead of a DictContainer * Add file_params to allow uploading files</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 0.3.33: </span>* Added the timeout kwarg</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.BaseClient.session_cookie"> <tt class="descname">session_cookie</tt><a class="headerlink" href="#fedora.client.BaseClient.session_cookie" title="Permalink to this definition">¶</a></dt> <dd><p><em>Deprecated</em>, use session_id instead.</p> <p>The session cookie is saved in a file in case it is needed in consecutive runs of BaseClient.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.BaseClient.session_id"> <tt class="descname">session_id</tt><a class="headerlink" href="#fedora.client.BaseClient.session_id" title="Permalink to this definition">¶</a></dt> <dd><p>The session_id.</p> <p>The session id is saved in a file in case it is needed in consecutive runs of BaseClient.</p> </dd></dl> </dd></dl> </div> <div class="section" id="proxyclient"> <h4>ProxyClient<a class="headerlink" href="#proxyclient" title="Permalink to this headline">¶</a></h4> <dl class="class"> <dt id="fedora.client.ProxyClient"> <em class="property">class </em><tt class="descclassname">fedora.client.</tt><tt class="descname">ProxyClient</tt><big>(</big><em>base_url</em>, <em>useragent=None</em>, <em>session_name='tg-visit'</em>, <em>session_as_cookie=True</em>, <em>debug=False</em>, <em>insecure=False</em>, <em>retries=None</em>, <em>timeout=None</em><big>)</big><a class="headerlink" href="#fedora.client.ProxyClient" title="Permalink to this definition">¶</a></dt> <dd><p>A client to a Fedora Service. This class is optimized to proxy multiple users to a service. ProxyClient is designed to be threadsafe so that code can instantiate one instance of the class and use it for multiple requests for different users from different threads.</p> <p>If you want something that can manage one user’s connection to a Fedora Service, then look into using BaseClient instead.</p> <p>This class has several attributes. These may be changed after instantiation however, please note that this class is intended to be threadsafe. Changing these values when another thread may affect more than just the thread that you are making the change in. (For instance, changing the debug option could cause other threads to start logging debug messages in the middle of a method.)</p> <dl class="attribute"> <dt id="fedora.client.ProxyClient.base_url"> <tt class="descname">base_url</tt><a class="headerlink" href="#fedora.client.ProxyClient.base_url" title="Permalink to this definition">¶</a></dt> <dd><p>Initial portion of the url to contact the server. It is highly recommended not to change this value unless you know that no other threads are accessing this <a class="reference internal" href="#fedora.client.ProxyClient" title="fedora.client.ProxyClient"><tt class="xref py py-class docutils literal"><span class="pre">ProxyClient</span></tt></a> instance.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.ProxyClient.useragent"> <tt class="descname">useragent</tt><a class="headerlink" href="#fedora.client.ProxyClient.useragent" title="Permalink to this definition">¶</a></dt> <dd><p>Changes the useragent string that is reported to the web server.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.ProxyClient.session_name"> <tt class="descname">session_name</tt><a class="headerlink" href="#fedora.client.ProxyClient.session_name" title="Permalink to this definition">¶</a></dt> <dd><p>Name of the cookie that holds the authentication value.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.ProxyClient.session_as_cookie"> <tt class="descname">session_as_cookie</tt><a class="headerlink" href="#fedora.client.ProxyClient.session_as_cookie" title="Permalink to this definition">¶</a></dt> <dd><p>If <tt class="xref py py-data docutils literal"><span class="pre">True</span></tt>, then the session information is saved locally as a cookie. This is here for backwards compatibility. New code should set this to <tt class="xref py py-data docutils literal"><span class="pre">False</span></tt> when constructing the <a class="reference internal" href="#fedora.client.ProxyClient" title="fedora.client.ProxyClient"><tt class="xref py py-class docutils literal"><span class="pre">ProxyClient</span></tt></a>.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.ProxyClient.debug"> <tt class="descname">debug</tt><a class="headerlink" href="#fedora.client.ProxyClient.debug" title="Permalink to this definition">¶</a></dt> <dd><p>If <tt class="xref py py-data docutils literal"><span class="pre">True</span></tt>, then more verbose logging is performed to aid in debugging issues.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.ProxyClient.insecure"> <tt class="descname">insecure</tt><a class="headerlink" href="#fedora.client.ProxyClient.insecure" title="Permalink to this definition">¶</a></dt> <dd><p>If <tt class="xref py py-data docutils literal"><span class="pre">True</span></tt> then the connection to the server is not checked to be sure that any SSL certificate information is valid. That means that a remote host can lie about who it is. Useful for development but should not be used in production code.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.ProxyClient.retries"> <tt class="descname">retries</tt><a class="headerlink" href="#fedora.client.ProxyClient.retries" title="Permalink to this definition">¶</a></dt> <dd><p>Setting this to a positive integer will retry failed requests to the web server this many times. Setting to a negative integer will retry forever.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.ProxyClient.timeout"> <tt class="descname">timeout</tt><a class="headerlink" href="#fedora.client.ProxyClient.timeout" title="Permalink to this definition">¶</a></dt> <dt> <tt class="descname">A float describing the timeout of the connection. The timeout only</tt></dt> <dt> <tt class="descname">affects the connection process itself, not the downloading of the</tt></dt> <dt> <tt class="descname">response body. Defaults to 120 seconds.</tt></dt> <dd></dd></dl> <p class="versionchanged"> <span class="versionmodified">Changed in version 0.3.33: </span>Added the timeout attribute</p> <dl class="attribute"> <dt> <tt class="descname">debug</tt></dt> <dd><p>When True, we log extra debugging statements. When False, we only log errors.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.ProxyClient.log"> <tt class="descname">log</tt><em class="property"> = <logging.Logger object at 0x24dc9d0></em><a class="headerlink" href="#fedora.client.ProxyClient.log" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="fedora.client.ProxyClient.send_request"> <tt class="descname">send_request</tt><big>(</big><em>method</em>, <em>req_params=None</em>, <em>auth_params=None</em>, <em>file_params=None</em>, <em>retries=None</em>, <em>timeout=None</em><big>)</big><a class="headerlink" href="#fedora.client.ProxyClient.send_request" title="Permalink to this definition">¶</a></dt> <dd><p>Make an HTTP request to a server method.</p> <p>The given method is called with any parameters set in <tt class="docutils literal"><span class="pre">req_params</span></tt>. If auth is True, then the request is made with an authenticated session cookie. Note that path parameters should be set by adding onto the method, not via <tt class="docutils literal"><span class="pre">req_params</span></tt>.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> <li><strong>method</strong> – Method to call on the server. It’s a url fragment that comes after the base_url set in __init__(). Note that any parameters set as extra path information should be listed here, not in <tt class="docutils literal"><span class="pre">req_params</span></tt>.</li> <li><strong>req_params</strong> – dict containing extra parameters to send to the server</li> <li><strong>auth_params</strong> – <p>dict containing one or more means of authenticating to the server. Valid entries in this dict are:</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">cookie:</th><td class="field-body"><strong>Deprecated</strong> Use <tt class="docutils literal"><span class="pre">session_id</span></tt> instead. If both <tt class="docutils literal"><span class="pre">cookie</span></tt> and <tt class="docutils literal"><span class="pre">session_id</span></tt> are set, only <tt class="docutils literal"><span class="pre">session_id</span></tt> will be used. A <tt class="docutils literal"><span class="pre">Cookie.SimpleCookie</span></tt> to send as a session cookie to the server</td> </tr> <tr class="field-even field"><th class="field-name">session_id:</th><td class="field-body">Session id to put in a cookie to construct an identity for the server</td> </tr> <tr class="field-odd field"><th class="field-name">username:</th><td class="field-body">Username to send to the server</td> </tr> <tr class="field-even field"><th class="field-name">password:</th><td class="field-body">Password to use with username to send to the server</td> </tr> <tr class="field-odd field"><th class="field-name">httpauth:</th><td class="field-body">If set to <tt class="docutils literal"><span class="pre">basic</span></tt> then use HTTP Basic Authentication to send the username and password to the server. This may be extended in the future to support other httpauth types than <tt class="docutils literal"><span class="pre">basic</span></tt>.</td> </tr> </tbody> </table> <p>Note that cookie can be sent alone but if one of username or password is set the other must as well. Code can set all of these if it wants and all of them will be sent to the server. Be careful of sending cookies that do not match with the username in this case as the server can decide what to do in this case.</p> </li> <li><strong>file_params</strong> – dict of files where the key is the name of the file field used in the remote method and the value is the local path of the file to be uploaded. If you want to pass multiple files to a single file field, pass the paths as a list of paths.</li> <li><strong>retries</strong> – if we get an unknown or possibly transient error from the server, retry this many times. Setting this to a negative number makes it try forever. Default to use the <a class="reference internal" href="#fedora.client.ProxyClient.retries" title="fedora.client.ProxyClient.retries"><tt class="xref py py-attr docutils literal"><span class="pre">retries</span></tt></a> value set on the instance or in <tt class="xref py py-meth docutils literal"><span class="pre">__init__()</span></tt>.</li> <li><strong>timeout</strong> – A float describing the timeout of the connection. The timeout only affects the connection process itself, not the downloading of the response body. Defaults to the <a class="reference internal" href="#fedora.client.ProxyClient.timeout" title="fedora.client.ProxyClient.timeout"><tt class="xref py py-attr docutils literal"><span class="pre">timeout</span></tt></a> value set on the instance or in <tt class="xref py py-meth docutils literal"><span class="pre">__init__()</span></tt>.</li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">If ProxyClient is created with session_as_cookie=True (the default), a tuple of session cookie and data from the server. If ProxyClient was created with session_as_cookie=False, a tuple of session_id and data instead.</p> </td> </tr> <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">tuple of session information and data from server</p> </td> </tr> </tbody> </table> <p class="versionchanged"> <span class="versionmodified">Changed in version 0.3.17: </span>No longer send tg_format=json parameter. We rely solely on the Accept: application/json header now.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 0.3.21: </span>* Return data as a Bunch instead of a DictContainer * Add file_params to allow uploading files</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 0.3.33: </span>Added the timeout kwarg</p> </dd></dl> </dd></dl> </div> <div class="section" id="openidbaseclient"> <h4>OpenIdBaseClient<a class="headerlink" href="#openidbaseclient" title="Permalink to this headline">¶</a></h4> <dl class="class"> <dt id="fedora.client.OpenIdBaseClient"> <em class="property">class </em><tt class="descclassname">fedora.client.</tt><tt class="descname">OpenIdBaseClient</tt><big>(</big><em>base_url</em>, <em>login_url=None</em>, <em>useragent=None</em>, <em>debug=False</em>, <em>insecure=False</em>, <em>openid_insecure=False</em>, <em>username=None</em>, <em>cache_session=True</em>, <em>retries=None</em>, <em>timeout=None</em>, <em>retry_backoff_factor=0</em><big>)</big><a class="headerlink" href="#fedora.client.OpenIdBaseClient" title="Permalink to this definition">¶</a></dt> <dd><p>A client for interacting with web services relying on openid auth.</p> <dl class="method"> <dt id="fedora.client.OpenIdBaseClient.has_cookies"> <tt class="descname">has_cookies</tt><big>(</big><big>)</big><a class="headerlink" href="#fedora.client.OpenIdBaseClient.has_cookies" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="fedora.client.OpenIdBaseClient.login"> <tt class="descname">login</tt><big>(</big><em>username</em>, <em>password</em>, <em>otp=None</em><big>)</big><a class="headerlink" href="#fedora.client.OpenIdBaseClient.login" title="Permalink to this definition">¶</a></dt> <dd><p>Open a session for the user.</p> <p>Log in the user with the specified username and password against the FAS OpenID server.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> <li><strong>username</strong> – the FAS username of the user that wants to log in</li> <li><strong>password</strong> – the FAS password of the user that wants to log in</li> <li><strong>otp</strong> – currently unused. Eventually a way to send an otp to the API that the API can use.</li> </ul> </td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="fedora.client.OpenIdBaseClient.send_request"> <tt class="descname">send_request</tt><big>(</big><em>method</em>, <em>auth=False</em>, <em>verb='POST'</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#fedora.client.OpenIdBaseClient.send_request" title="Permalink to this definition">¶</a></dt> <dd><p>Make an HTTP request to a server method.</p> <p>The given method is called with any parameters set in req_params. If auth is True, then the request is made with an authenticated session cookie.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> <li><strong>method</strong> – Method to call on the server. It’s a url fragment that comes after the <tt class="xref py py-attr docutils literal"><span class="pre">base_url</span></tt> set in <tt class="xref py py-meth docutils literal"><span class="pre">__init__()</span></tt>.</li> <li><strong>auth</strong> – If True perform auth to the server, else do not.</li> <li><strong>req_params</strong> – Extra parameters to send to the server.</li> <li><strong>file_params</strong> – dict of files where the key is the name of the file field used in the remote method and the value is the local path of the file to be uploaded. If you want to pass multiple files to a single file field, pass the paths as a list of paths.</li> <li><strong>verb</strong> – HTTP verb to use. GET and POST are currently supported. POST is the default.</li> </ul> </td> </tr> </tbody> </table> </dd></dl> <dl class="attribute"> <dt id="fedora.client.OpenIdBaseClient.session_key"> <tt class="descname">session_key</tt><a class="headerlink" href="#fedora.client.OpenIdBaseClient.session_key" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> </dd></dl> <dl class="function"> <dt id="fedora.client.openidbaseclient.requires_login"> <tt class="descclassname">fedora.client.openidbaseclient.</tt><tt class="descname">requires_login</tt><big>(</big><em>func</em><big>)</big><a class="headerlink" href="#fedora.client.openidbaseclient.requires_login" title="Permalink to this definition">¶</a></dt> <dd><p>Decorator function for get or post requests requiring login.</p> <p>Decorate a controller method that requires the user to be authenticated. Example:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">fedora.client.openidbaseclient</span> <span class="kn">import</span> <span class="n">requires_login</span> <span class="nd">@requires_login</span> <span class="k">def</span> <span class="nf">rename_user</span><span class="p">(</span><span class="n">new_name</span><span class="p">):</span> <span class="n">user</span> <span class="o">=</span> <span class="n">new_name</span> <span class="c"># [...]</span> </pre></div> </div> </dd></dl> </div> <div class="section" id="openidproxyclient"> <h4>OpenIdProxyClient<a class="headerlink" href="#openidproxyclient" title="Permalink to this headline">¶</a></h4> <dl class="class"> <dt id="fedora.client.OpenIdProxyClient"> <em class="property">class </em><tt class="descclassname">fedora.client.</tt><tt class="descname">OpenIdProxyClient</tt><big>(</big><em>base_url</em>, <em>login_url=None</em>, <em>useragent=None</em>, <em>session_name='session'</em>, <em>debug=False</em>, <em>insecure=False</em>, <em>openid_insecure=False</em>, <em>retries=None</em>, <em>timeout=None</em><big>)</big><a class="headerlink" href="#fedora.client.OpenIdProxyClient" title="Permalink to this definition">¶</a></dt> <dd><p>A client to a Fedora Service. This class is optimized to proxy multiple users to a service. OpenIdProxyClient is designed to be usable by code that creates a single instance of this class and uses it in multiple threads. However it is not completely threadsafe. See the information on setting attributes below.</p> <p>If you want something that can manage one user’s connection to a Fedora Service, then look into using <a class="reference internal" href="#fedora.client.OpenIdBaseClient" title="fedora.client.OpenIdBaseClient"><tt class="xref py py-class docutils literal"><span class="pre">OpenIdBaseClient</span></tt></a> instead.</p> <p>This class has several attributes. These may be changed after instantiation. Please note, however, that changing these values when another thread is utilizing the same instance may affect more than just the thread that you are making the change in. (For instance, changing the debug option could cause other threads to start logging debug messages in the middle of a method.)</p> <dl class="attribute"> <dt id="fedora.client.OpenIdProxyClient.base_url"> <tt class="descname">base_url</tt><a class="headerlink" href="#fedora.client.OpenIdProxyClient.base_url" title="Permalink to this definition">¶</a></dt> <dd><p>Initial portion of the url to contact the server. It is highly recommended not to change this value unless you know that no other threads are accessing this <a class="reference internal" href="#fedora.client.OpenIdProxyClient" title="fedora.client.OpenIdProxyClient"><tt class="xref py py-class docutils literal"><span class="pre">OpenIdProxyClient</span></tt></a> instance.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.OpenIdProxyClient.useragent"> <tt class="descname">useragent</tt><a class="headerlink" href="#fedora.client.OpenIdProxyClient.useragent" title="Permalink to this definition">¶</a></dt> <dd><p>Changes the useragent string that is reported to the web server.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.OpenIdProxyClient.session_name"> <tt class="descname">session_name</tt><a class="headerlink" href="#fedora.client.OpenIdProxyClient.session_name" title="Permalink to this definition">¶</a></dt> <dd><p>Name of the cookie that holds the authentication value.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.OpenIdProxyClient.debug"> <tt class="descname">debug</tt><a class="headerlink" href="#fedora.client.OpenIdProxyClient.debug" title="Permalink to this definition">¶</a></dt> <dd><p>If <tt class="xref py py-data docutils literal"><span class="pre">True</span></tt>, then more verbose logging is performed to aid in debugging issues.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.OpenIdProxyClient.insecure"> <tt class="descname">insecure</tt><a class="headerlink" href="#fedora.client.OpenIdProxyClient.insecure" title="Permalink to this definition">¶</a></dt> <dd><p>If <tt class="xref py py-data docutils literal"><span class="pre">True</span></tt> then the connection to the server is not checked to be sure that any SSL certificate information is valid. That means that a remote host can lie about who it is. Useful for development but should not be used in production code.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.OpenIdProxyClient.retries"> <tt class="descname">retries</tt><a class="headerlink" href="#fedora.client.OpenIdProxyClient.retries" title="Permalink to this definition">¶</a></dt> <dd><p>Setting this to a positive integer will retry failed requests to the web server this many times. Setting to a negative integer will retry forever.</p> </dd></dl> <dl class="attribute"> <dt id="fedora.client.OpenIdProxyClient.timeout"> <tt class="descname">timeout</tt><a class="headerlink" href="#fedora.client.OpenIdProxyClient.timeout" title="Permalink to this definition">¶</a></dt> <dd><p>A float describing the timeout of the connection. The timeout only affects the connection process itself, not the downloading of the response body. Defaults to 120 seconds.</p> </dd></dl> <dl class="attribute"> <dt> <tt class="descname">debug</tt></dt> <dd><p>When True, we log extra debugging statements. When False, we only log errors.</p> </dd></dl> <dl class="method"> <dt id="fedora.client.OpenIdProxyClient.login"> <tt class="descname">login</tt><big>(</big><em>username</em>, <em>password</em>, <em>otp=None</em><big>)</big><a class="headerlink" href="#fedora.client.OpenIdProxyClient.login" title="Permalink to this definition">¶</a></dt> <dd><p>Open a session for the user.</p> <p>Log in the user with the specified username and password against the FAS OpenID server.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> <li><strong>username</strong> – the FAS username of the user that wants to log in</li> <li><strong>password</strong> – the FAS password of the user that wants to log in</li> <li><strong>otp</strong> – currently unused. Eventually a way to send an otp to the API that the API can use.</li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a tuple containing both the response from the OpenID provider and the session used to by this provider.</p> </td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="fedora.client.OpenIdProxyClient.send_request"> <tt class="descname">send_request</tt><big>(</big><em>method</em>, <em>verb='POST'</em>, <em>req_params=None</em>, <em>auth_params=None</em>, <em>file_params=None</em>, <em>retries=None</em>, <em>timeout=None</em>, <em>headers=None</em><big>)</big><a class="headerlink" href="#fedora.client.OpenIdProxyClient.send_request" title="Permalink to this definition">¶</a></dt> <dd><p>Make an HTTP request to a server method.</p> <p>The given method is called with any parameters set in <tt class="docutils literal"><span class="pre">req_params</span></tt>. If auth is True, then the request is made with an authenticated session cookie. Note that path parameters should be set by adding onto the method, not via <tt class="docutils literal"><span class="pre">req_params</span></tt>.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> <li><strong>method</strong> – Method to call on the server. It’s a url fragment that comes after the base_url set in __init__(). Note that any parameters set as extra path information should be listed here, not in <tt class="docutils literal"><span class="pre">req_params</span></tt>.</li> <li><strong>req_params</strong> – dict containing extra parameters to send to the server</li> <li><strong>auth_params</strong> – <p>dict containing one or more means of authenticating to the server. Valid entries in this dict are:</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">cookie:</th><td class="field-body"><strong>Deprecated</strong> Use <tt class="docutils literal"><span class="pre">session_id</span></tt> instead. If both <tt class="docutils literal"><span class="pre">cookie</span></tt> and <tt class="docutils literal"><span class="pre">session_id</span></tt> are set, only <tt class="docutils literal"><span class="pre">session_id</span></tt> will be used. A <tt class="docutils literal"><span class="pre">Cookie.SimpleCookie</span></tt> to send as a session cookie to the server</td> </tr> <tr class="field-even field"><th class="field-name">session_id:</th><td class="field-body">Session id to put in a cookie to construct an identity for the server</td> </tr> <tr class="field-odd field"><th class="field-name">username:</th><td class="field-body">Username to send to the server</td> </tr> <tr class="field-even field"><th class="field-name">password:</th><td class="field-body">Password to use with username to send to the server</td> </tr> <tr class="field-odd field"><th class="field-name">httpauth:</th><td class="field-body">If set to <tt class="docutils literal"><span class="pre">basic</span></tt> then use HTTP Basic Authentication to send the username and password to the server. This may be extended in the future to support other httpauth types than <tt class="docutils literal"><span class="pre">basic</span></tt>.</td> </tr> </tbody> </table> <p>Note that cookie can be sent alone but if one of username or password is set the other must as well. Code can set all of these if it wants and all of them will be sent to the server. Be careful of sending cookies that do not match with the username in this case as the server can decide what to do in this case.</p> </li> <li><strong>file_params</strong> – dict of files where the key is the name of the file field used in the remote method and the value is the local path of the file to be uploaded. If you want to pass multiple files to a single file field, pass the paths as a list of paths.</li> <li><strong>retries</strong> – if we get an unknown or possibly transient error from the server, retry this many times. Setting this to a negative number makes it try forever. Default to use the <a class="reference internal" href="#fedora.client.OpenIdProxyClient.retries" title="fedora.client.OpenIdProxyClient.retries"><tt class="xref py py-attr docutils literal"><span class="pre">retries</span></tt></a> value set on the instance or in <tt class="xref py py-meth docutils literal"><span class="pre">__init__()</span></tt>.</li> <li><strong>timeout</strong> – A float describing the timeout of the connection. The timeout only affects the connection process itself, not the downloading of the response body. Defaults to the <a class="reference internal" href="#fedora.client.OpenIdProxyClient.timeout" title="fedora.client.OpenIdProxyClient.timeout"><tt class="xref py py-attr docutils literal"><span class="pre">timeout</span></tt></a> value set on the instance or in <tt class="xref py py-meth docutils literal"><span class="pre">__init__()</span></tt>.</li> <li><strong>headers</strong> – A dictionary containing specific headers to add to the request made.</li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A tuple of session_id and data.</p> </td> </tr> <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">tuple of session information and data from server</p> </td> </tr> </tbody> </table> </dd></dl> </dd></dl> </div> </div> <div class="section" id="clients-for-specific-services"> <h3>Clients for Specific Services<a class="headerlink" href="#clients-for-specific-services" title="Permalink to this headline">¶</a></h3> <div class="section" id="wiki"> <h4>Wiki<a class="headerlink" href="#wiki" title="Permalink to this headline">¶</a></h4> <dl class="class"> <dt id="fedora.client.Wiki"> <em class="property">class </em><tt class="descclassname">fedora.client.</tt><tt class="descname">Wiki</tt><big>(</big><em>base_url='https://fedoraproject.org/w/'</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#fedora.client.Wiki" title="Permalink to this definition">¶</a></dt> <dd><dl class="attribute"> <dt id="fedora.client.Wiki.api_high_limits"> <tt class="descname">api_high_limits</tt><em class="property"> = False</em><a class="headerlink" href="#fedora.client.Wiki.api_high_limits" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="fedora.client.Wiki.check_api_limits"> <tt class="descname">check_api_limits</tt><big>(</big><big>)</big><a class="headerlink" href="#fedora.client.Wiki.check_api_limits" title="Permalink to this definition">¶</a></dt> <dd><p>Checks whether you have the ‘apihighlimits’ right or not.</p> </dd></dl> <dl class="method"> <dt id="fedora.client.Wiki.fetch_all_revisions"> <tt class="descname">fetch_all_revisions</tt><big>(</big><em>start=1</em>, <em>flags=True</em>, <em>timestamp=True</em>, <em>user=True</em>, <em>size=False</em>, <em>comment=True</em>, <em>content=False</em>, <em>title=True</em>, <em>ignore_imported_revs=True</em>, <em>ignore_wikibot=False</em>, <em>callback=None</em><big>)</big><a class="headerlink" href="#fedora.client.Wiki.fetch_all_revisions" title="Permalink to this definition">¶</a></dt> <dd><p>Fetch data for all revisions. This could take a long time. You can start at a specific revision by modifying the ‘start’ keyword argument.</p> <p>To ignore revisions made by “ImportUser” and “Admin” set ignore_imported_revs to True (this is the default). To ignore edits made by Wikibot set ignore_wikibot to True (False is the default).</p> <p>Modifying the remainder of the keyword arguments will return less/more data.</p> </dd></dl> <dl class="method"> <dt id="fedora.client.Wiki.get_recent_changes"> <tt class="descname">get_recent_changes</tt><big>(</big><em>now</em>, <em>then</em>, <em>limit=500</em><big>)</big><a class="headerlink" href="#fedora.client.Wiki.get_recent_changes" title="Permalink to this definition">¶</a></dt> <dd><p>Get recent wiki changes from <cite>now</cite> until <cite>then</cite></p> </dd></dl> <dl class="method"> <dt id="fedora.client.Wiki.login"> <tt class="descname">login</tt><big>(</big><em>username</em>, <em>password</em><big>)</big><a class="headerlink" href="#fedora.client.Wiki.login" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="fedora.client.Wiki.print_recent_changes"> <tt class="descname">print_recent_changes</tt><big>(</big><em>days=7</em>, <em>show=10</em><big>)</big><a class="headerlink" href="#fedora.client.Wiki.print_recent_changes" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> </dd></dl> </div> </div> </div> <div class="section" id="service"> <h2>Service<a class="headerlink" href="#service" title="Permalink to this headline">¶</a></h2> <div class="section" id="transforming-sqlalchemy-objects-into-json"> <h3>Transforming SQLAlchemy Objects into JSON<a class="headerlink" href="#transforming-sqlalchemy-objects-into-json" title="Permalink to this headline">¶</a></h3> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">API Documentation</a><ul> <li><a class="reference internal" href="#module-fedora.client">Client</a><ul> <li><a class="reference internal" href="#generic-clients">Generic Clients</a><ul> <li><a class="reference internal" href="#baseclient">BaseClient</a></li> <li><a class="reference internal" href="#proxyclient">ProxyClient</a></li> <li><a class="reference internal" href="#openidbaseclient">OpenIdBaseClient</a></li> <li><a class="reference internal" href="#openidproxyclient">OpenIdProxyClient</a></li> </ul> </li> <li><a class="reference internal" href="#clients-for-specific-services">Clients for Specific Services</a><ul> <li><a class="reference internal" href="#wiki">Wiki</a></li> </ul> </li> </ul> </li> <li><a class="reference internal" href="#service">Service</a><ul> <li><a class="reference internal" href="#transforming-sqlalchemy-objects-into-json">Transforming SQLAlchemy Objects into JSON</a></li> </ul> </li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="javascript.html" title="previous chapter">JavaScript</a></p> <h4>Next topic</h4> <p class="topless"><a href="glossary.html" title="next chapter">Glossary</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/api.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="glossary.html" title="Glossary" >next</a> |</li> <li class="right" > <a href="javascript.html" title="JavaScript" >previous</a> |</li> <li><a href="index.html">python-fedora 0.10.0 documentation</a> »</li> </ul> </div> <div class="footer"> © Copyright 2007-2018 Red Hat, Inc.. Last updated on Feb 01, 2018. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>