forked from googleapis/google-cloud-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconnection.html
More file actions
139 lines (114 loc) · 7.29 KB
/
connection.html
File metadata and controls
139 lines (114 loc) · 7.29 KB
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
<!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>gcloud.connection — gcloud 0.1 documentation</title>
<link rel="stylesheet" href="../../_static/style.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '0.1',
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>
<script type="text/javascript" src="../../_static/sidebar.js"></script>
<link rel="top" title="gcloud 0.1 documentation" href="../../index.html" />
<link rel="up" title="Module code" href="../index.html" />
</head>
<body role="document" class="two-column docs"><a href="https://github.com/GoogleCloudPlatform/gcloud-python"><img style="position: absolute; top: 0; right: 0; border: 0; z-index: 999;" src="_static/forkme.png" alt="Fork me on GitHub"></a>
<div id="sandbar">
<header id="gc-googlebar">
<a id="gc-logo" href="../../index.html">
<img src="_static/cloudplatform-horizontal.png" alt="Google">
</a>
<form class="gc-search" action="search.html" method="GET">
<div class="searchbox" style="width: 429px;">
<span class="button button-blue mini">Google Cloud Python API</span>
<input type="hidden" name="check_keywords" value="yes">
<input type="hidden" name="area" value="default">
<input type="text" name="q" class="q" id="q" value=""
placeholder="Search" autocomplete="off" style="width: 263px;">
</div>
<button class="button button-blue" style="top: 0px; left: 444px;">
<img src="_static/search.png" alt="Search">
</button>
<input type="hidden" name="p" id="search_project" value="/compute">
</form>
</header>
</div>
<div id="gc-wrapper">
<div id="gc-appbar">
<h1><a href="../../index.html">gcloud 0.1 documentation</a></h1>
</div>
<div id="gc-main" class="main">
<div id="gc-sidebar" class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3>All API Docs</h3>
<nav class="gc-toc">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../datastore-api.html">Cloud Datastore</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../storage-api.html">Cloud Storage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../common-api.html">Cloud Common</a></li>
</ul>
</nav>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main" id="gc-content">
<h1>Source code for gcloud.connection</h1><div class="highlight"><pre>
<span class="kn">import</span> <span class="nn">httplib2</span>
<div class="viewcode-block" id="Connection"><a class="viewcode-back" href="../../common-api.html#gcloud.connection.Connection">[docs]</a><span class="k">class</span> <span class="nc">Connection</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">"""A generic connection to Google Cloud Platform.</span>
<span class="sd"> Subclasses should understand</span>
<span class="sd"> only the basic types</span>
<span class="sd"> in method arguments,</span>
<span class="sd"> however they should be capable</span>
<span class="sd"> of returning advanced types.</span>
<span class="sd"> """</span>
<span class="n">API_BASE_URL</span> <span class="o">=</span> <span class="s">'https://www.googleapis.com'</span>
<span class="sd">"""The base of the API call URL."""</span>
<span class="n">_EMPTY</span> <span class="o">=</span> <span class="nb">object</span><span class="p">()</span>
<span class="sd">"""A pointer to represent an empty value for default arguments."""</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">credentials</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> :type credentials: :class:`gcloud.credentials.Credentials`</span>
<span class="sd"> :param credentials: The OAuth2 Credentials to use for this connection.</span>
<span class="sd"> """</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_credentials</span> <span class="o">=</span> <span class="n">credentials</span>
<span class="nd">@property</span>
<div class="viewcode-block" id="Connection.http"><a class="viewcode-back" href="../../common-api.html#gcloud.connection.Connection.http">[docs]</a> <span class="k">def</span> <span class="nf">http</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">"""A getter for the HTTP transport used in talking to the API.</span>
<span class="sd"> :rtype: :class:`httplib2.Http`</span>
<span class="sd"> :returns: A Http object used to transport data.</span>
<span class="sd"> """</span>
<span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s">'_http'</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_http</span> <span class="o">=</span> <span class="n">httplib2</span><span class="o">.</span><span class="n">Http</span><span class="p">()</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_credentials</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_http</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_credentials</span><span class="o">.</span><span class="n">authorize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_http</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_http</span>
</pre></div></div></div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
</div>
<footer id="gc-footer" class="footer" role="contentinfo">
<div id="gc-copyright">
© Copyright 2014, JJ Geewax.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.1.
</div>
</footer>
</body>
</html>