/usr/share/doc/python-gitlab/html/switching-to-v4.html is in python-gitlab-doc 1:1.3.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | <!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>Switching to GitLab API v4 — python-gitlab 1.3.0 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.3.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</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="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="API examples" href="api-objects.html" />
<link rel="prev" title="Getting started with the API" href="api-usage.html" />
</head>
<body>
<div class="related" role="navigation" aria-label="related navigation">
<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="api-objects.html" title="API examples"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="api-usage.html" title="Getting started with the API"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">python-gitlab 1.3.0 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="switching-to-gitlab-api-v4">
<span id="switching-to-v4"></span><h1>Switching to GitLab API v4<a class="headerlink" href="#switching-to-gitlab-api-v4" title="Permalink to this headline">¶</a></h1>
<p>GitLab provides a new API version (v4) since its 9.0 release. <code class="docutils literal"><span class="pre">python-gitlab</span></code>
provides support for this new version, but the python API has been modified to
solve some problems with the existing one.</p>
<p>GitLab will stop supporting the v3 API soon, and you should consider switching
to v4 if you use a recent version of GitLab (>= 9.0), or if you use
<a class="reference external" href="http://gitlab.com">http://gitlab.com</a>.</p>
<div class="section" id="using-the-v4-api">
<h2>Using the v4 API<a class="headerlink" href="#using-the-v4-api" title="Permalink to this headline">¶</a></h2>
<p>python-gitlab uses the v4 API by default since the 1.3.0 release. To use the
old v3 API, explicitly define <code class="docutils literal"><span class="pre">api_version</span></code> in the <code class="docutils literal"><span class="pre">Gitlab</span></code> constructor:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">gl</span> <span class="o">=</span> <span class="n">gitlab</span><span class="o">.</span><span class="n">Gitlab</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">api_version</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
</pre></div>
</div>
<p>If you use the configuration file, also explicitly define the version:</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[my_gitlab]</span>
<span class="na">...</span>
<span class="na">api_version</span> <span class="o">=</span> <span class="s">3</span>
</pre></div>
</div>
</div>
<div class="section" id="changes-between-v3-and-v4-api">
<h2>Changes between v3 and v4 API<a class="headerlink" href="#changes-between-v3-and-v4-api" title="Permalink to this headline">¶</a></h2>
<p>For a list of GitLab (upstream) API changes, see
<a class="reference external" href="https://docs.gitlab.com/ce/api/v3_to_v4.html">https://docs.gitlab.com/ce/api/v3_to_v4.html</a>.</p>
<p>The <code class="docutils literal"><span class="pre">python-gitlab</span></code> API reflects these changes. But also consider the
following important changes in the python API:</p>
<ul>
<li><p class="first">managers and objects don’t inherit from <code class="docutils literal"><span class="pre">GitlabObject</span></code> and <code class="docutils literal"><span class="pre">BaseManager</span></code>
anymore. They inherit from <a class="reference internal" href="api/gitlab.html#gitlab.base.RESTManager" title="gitlab.base.RESTManager"><code class="xref py py-class docutils literal"><span class="pre">RESTManager</span></code></a> and
<a class="reference internal" href="api/gitlab.html#gitlab.base.RESTObject" title="gitlab.base.RESTObject"><code class="xref py py-class docutils literal"><span class="pre">RESTObject</span></code></a>.</p>
</li>
<li><p class="first">You should only use the managers to perform CRUD operations.</p>
<p>The following v3 code:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">gl</span> <span class="o">=</span> <span class="n">gitlab</span><span class="o">.</span><span class="n">Gitlab</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">Project</span><span class="p">(</span><span class="n">gl</span><span class="p">,</span> <span class="n">project_id</span><span class="p">)</span>
</pre></div>
</div>
<p>Should be replaced with:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">gl</span> <span class="o">=</span> <span class="n">gitlab</span><span class="o">.</span><span class="n">Gitlab</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">gl</span><span class="o">.</span><span class="n">projects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">project_id</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">Listing methods (<code class="docutils literal"><span class="pre">manager.list()</span></code> for instance) can now return generators
(<a class="reference internal" href="api/gitlab.html#gitlab.base.RESTObjectList" title="gitlab.base.RESTObjectList"><code class="xref py py-class docutils literal"><span class="pre">RESTObjectList</span></code></a>). They handle the calls to the API when
needed to fetch new items.</p>
<p>By default you will still get lists. To get generators use <code class="docutils literal"><span class="pre">as_list=False</span></code>:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">all_projects_g</span> <span class="o">=</span> <span class="n">gl</span><span class="o">.</span><span class="n">projects</span><span class="o">.</span><span class="n">list</span><span class="p">(</span><span class="n">as_list</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">The “nested” managers (for instance <code class="docutils literal"><span class="pre">gl.project_issues</span></code> or
<code class="docutils literal"><span class="pre">gl.group_members</span></code>) are not available anymore. Their goal was to provide a
direct way to manage nested objects, and to limit the number of needed API
calls.</p>
<p>To limit the number of API calls, you can now use <code class="docutils literal"><span class="pre">get()</span></code> methods with the
<code class="docutils literal"><span class="pre">lazy=True</span></code> parameter. This creates shallow objects that provide usual
managers.</p>
<p>The following v3 code:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">issues</span> <span class="o">=</span> <span class="n">gl</span><span class="o">.</span><span class="n">project_issues</span><span class="o">.</span><span class="n">list</span><span class="p">(</span><span class="n">project_id</span><span class="o">=</span><span class="n">project_id</span><span class="p">)</span>
</pre></div>
</div>
<p>Should be replaced with:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">issues</span> <span class="o">=</span> <span class="n">gl</span><span class="o">.</span><span class="n">projects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">project_id</span><span class="p">,</span> <span class="n">lazy</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span><span class="o">.</span><span class="n">issues</span><span class="o">.</span><span class="n">list</span><span class="p">()</span>
</pre></div>
</div>
<p>This will make only one API call, instead of two if <code class="docutils literal"><span class="pre">lazy</span></code> is not used.</p>
</li>
<li><p class="first">The following <a class="reference internal" href="api/gitlab.html#gitlab.Gitlab" title="gitlab.Gitlab"><code class="xref py py-class docutils literal"><span class="pre">Gitlab</span></code></a> methods should not be used anymore for
v4:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">list()</span></code></li>
<li><code class="docutils literal"><span class="pre">get()</span></code></li>
<li><code class="docutils literal"><span class="pre">create()</span></code></li>
<li><code class="docutils literal"><span class="pre">update()</span></code></li>
<li><code class="docutils literal"><span class="pre">delete()</span></code></li>
</ul>
</li>
<li><p class="first">If you need to perform HTTP requests to the GitLab server (which you
shouldn’t), you can use the following <a class="reference internal" href="api/gitlab.html#gitlab.Gitlab" title="gitlab.Gitlab"><code class="xref py py-class docutils literal"><span class="pre">Gitlab</span></code></a> methods:</p>
<ul class="simple">
<li><a class="reference internal" href="api/gitlab.html#gitlab.Gitlab.http_request" title="gitlab.Gitlab.http_request"><code class="xref py py-attr docutils literal"><span class="pre">http_request</span></code></a></li>
<li><a class="reference internal" href="api/gitlab.html#gitlab.Gitlab.http_get" title="gitlab.Gitlab.http_get"><code class="xref py py-attr docutils literal"><span class="pre">http_get</span></code></a></li>
<li><a class="reference internal" href="api/gitlab.html#gitlab.Gitlab.http_list" title="gitlab.Gitlab.http_list"><code class="xref py py-attr docutils literal"><span class="pre">http_list</span></code></a></li>
<li><a class="reference internal" href="api/gitlab.html#gitlab.Gitlab.http_post" title="gitlab.Gitlab.http_post"><code class="xref py py-attr docutils literal"><span class="pre">http_post</span></code></a></li>
<li><a class="reference internal" href="api/gitlab.html#gitlab.Gitlab.http_put" title="gitlab.Gitlab.http_put"><code class="xref py py-attr docutils literal"><span class="pre">http_put</span></code></a></li>
<li><a class="reference internal" href="api/gitlab.html#gitlab.Gitlab.http_delete" title="gitlab.Gitlab.http_delete"><code class="xref py py-attr docutils literal"><span class="pre">http_delete</span></code></a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Switching to GitLab API v4</a><ul>
<li><a class="reference internal" href="#using-the-v4-api">Using the v4 API</a></li>
<li><a class="reference internal" href="#changes-between-v3-and-v4-api">Changes between v3 and v4 API</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="api-usage.html"
title="previous chapter">Getting started with the API</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="api-objects.html"
title="next chapter">API examples</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/switching-to-v4.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<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="api-objects.html" title="API examples"
>next</a> |</li>
<li class="right" >
<a href="api-usage.html" title="Getting started with the API"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">python-gitlab 1.3.0 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2013-2018, Gauvain Pocentek, Mika Mäenpää.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.7.
</div>
</body>
</html>
|