-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0bd4097
Showing
55 changed files
with
11,123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 959aa8e1cbad269255e4be71235447d9 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en" data-content_root="../"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Overview: module code — sxapi 0.0.post1.dev1+g7d2f9e6 documentation</title> | ||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=fa44fd50" /> | ||
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css?v=233b9934" /> | ||
<script src="../_static/documentation_options.js?v=becd8700"></script> | ||
<script src="../_static/doctools.js?v=888ff710"></script> | ||
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script> | ||
<link rel="index" title="Index" href="../genindex.html" /> | ||
<link rel="search" title="Search" href="../search.html" /> | ||
|
||
<link rel="stylesheet" href="../_static/custom.css" type="text/css" /> | ||
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> | ||
|
||
</head><body> | ||
|
||
|
||
<div class="document"> | ||
<div class="documentwrapper"> | ||
<div class="bodywrapper"> | ||
|
||
|
||
<div class="body" role="main"> | ||
|
||
<h1>All modules for which code is available</h1> | ||
<ul><li><a href="sxapi/base.html">sxapi.base</a></li> | ||
<li><a href="sxapi/cli/cli.html">sxapi.cli.cli</a></li> | ||
<li><a href="sxapi/cli/cli_user.html">sxapi.cli.cli_user</a></li> | ||
<li><a href="sxapi/cli/subparser/get_sensor_data.html">sxapi.cli.subparser.get_sensor_data</a></li> | ||
<li><a href="sxapi/cli/subparser/token.html">sxapi.cli.subparser.token</a></li> | ||
<li><a href="sxapi/publicV2.html">sxapi.publicV2</a></li> | ||
<ul><li><a href="sxapi/publicV2/alarms.html">sxapi.publicV2.alarms</a></li> | ||
<li><a href="sxapi/publicV2/data.html">sxapi.publicV2.data</a></li> | ||
<li><a href="sxapi/publicV2/feedrations.html">sxapi.publicV2.feedrations</a></li> | ||
<li><a href="sxapi/publicV2/groups.html">sxapi.publicV2.groups</a></li> | ||
<li><a href="sxapi/publicV2/sensordata.html">sxapi.publicV2.sensordata</a></li> | ||
<li><a href="sxapi/publicV2/todos.html">sxapi.publicV2.todos</a></li> | ||
<li><a href="sxapi/publicV2/users.html">sxapi.publicV2.users</a></li> | ||
</ul></ul> | ||
|
||
</div> | ||
|
||
</div> | ||
</div> | ||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation"> | ||
<div class="sphinxsidebarwrapper"> | ||
<h1 class="logo"><a href="../index.html">sxapi</a></h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h3>Navigation</h3> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../readme.html">Overview</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Contributions & Help</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../authors.html">Authors</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../changelog.html">Changelog</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../api/modules.html">Module Reference</a></li> | ||
</ul> | ||
|
||
<div class="relations"> | ||
<h3>Related Topics</h3> | ||
<ul> | ||
<li><a href="../index.html">Documentation overview</a><ul> | ||
</ul></li> | ||
</ul> | ||
</div> | ||
<div id="searchbox" style="display: none" role="search"> | ||
<h3 id="searchlabel">Quick search</h3> | ||
<div class="searchformwrapper"> | ||
<form class="search" action="../search.html" method="get"> | ||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> | ||
<input type="submit" value="Go" /> | ||
</form> | ||
</div> | ||
</div> | ||
<script>document.getElementById('searchbox').style.display = "block"</script> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</div> | ||
</div> | ||
<div class="clearer"></div> | ||
</div> | ||
<div class="footer"> | ||
©2021, Florian Klien. | ||
|
||
| | ||
Powered by <a href="http://sphinx-doc.org/">Sphinx 7.2.6</a> | ||
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a> | ||
|
||
</div> | ||
|
||
|
||
|
||
|
||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en" data-content_root="../../../"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>sxapi.cli.cli_user — sxapi 0.0.post1.dev1+g7d2f9e6 documentation</title> | ||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=fa44fd50" /> | ||
<link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css?v=233b9934" /> | ||
<script src="../../../_static/documentation_options.js?v=becd8700"></script> | ||
<script src="../../../_static/doctools.js?v=888ff710"></script> | ||
<script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script> | ||
<link rel="index" title="Index" href="../../../genindex.html" /> | ||
<link rel="search" title="Search" href="../../../search.html" /> | ||
|
||
<link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> | ||
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> | ||
|
||
</head><body> | ||
|
||
|
||
<div class="document"> | ||
<div class="documentwrapper"> | ||
<div class="bodywrapper"> | ||
|
||
|
||
<div class="body" role="main"> | ||
|
||
<h1>Source code for sxapi.cli.cli_user</h1><div class="highlight"><pre> | ||
<span></span><span class="kn">import</span> <span class="nn">os</span> | ||
|
||
<span class="kn">import</span> <span class="nn">keyring</span> | ||
|
||
<span class="kn">from</span> <span class="nn">sxapi.base</span> <span class="kn">import</span> <span class="n">IntegrationAPIV2</span> | ||
<span class="kn">from</span> <span class="nn">sxapi.publicV2</span> <span class="kn">import</span> <span class="n">PublicAPIV2</span> | ||
|
||
|
||
<div class="viewcode-block" id="CliUser"> | ||
<a class="viewcode-back" href="../../../api/sxapi.cli.html#sxapi.cli.cli_user.CliUser">[docs]</a> | ||
<span class="k">class</span> <span class="nc">CliUser</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> CliUser class used for initializing, storing, retrieving and deleting</span> | ||
<span class="sd"> credentials and creating/holding Instances of supported API</span> | ||
<span class="sd"> Client.</span> | ||
|
||
<span class="sd"> This class should only be used in the cli package.</span> | ||
<span class="sd"> """</span> | ||
|
||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> Basic User Credentials Constructor</span> | ||
|
||
<span class="sd"> calls self._init_creds() to set available credentials on startup.</span> | ||
<span class="sd"> """</span> | ||
|
||
<span class="bp">self</span><span class="o">.</span><span class="n">api_access_token</span> <span class="o">=</span> <span class="kc">None</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">public_v2_api</span> <span class="o">=</span> <span class="kc">None</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">integration_v2_api</span> <span class="o">=</span> <span class="kc">None</span> | ||
|
||
<div class="viewcode-block" id="CliUser.get_token_environment"> | ||
<a class="viewcode-back" href="../../../api/sxapi.cli.html#sxapi.cli.cli_user.CliUser.get_token_environment">[docs]</a> | ||
<span class="nd">@staticmethod</span> | ||
<span class="k">def</span> <span class="nf">get_token_environment</span><span class="p">():</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> Gets token named 'SMAXTEC_API_ACCESS_TOKEN' from the systems' environment.</span> | ||
<span class="sd"> """</span> | ||
|
||
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"SMAXTEC_API_ACCESS_TOKEN"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span></div> | ||
|
||
|
||
<div class="viewcode-block" id="CliUser.set_token_keyring"> | ||
<a class="viewcode-back" href="../../../api/sxapi.cli.html#sxapi.cli.cli_user.CliUser.set_token_keyring">[docs]</a> | ||
<span class="k">def</span> <span class="nf">set_token_keyring</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token</span><span class="p">):</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> Store the given token in keyring.</span> | ||
<span class="sd"> """</span> | ||
<span class="n">keyring</span><span class="o">.</span><span class="n">set_password</span><span class="p">(</span><span class="s2">"sxapi"</span><span class="p">,</span> <span class="s2">"SMAXTEC_API_ACCESS_TOKEN"</span><span class="p">,</span> <span class="n">token</span><span class="p">)</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">api_access_token</span> <span class="o">=</span> <span class="n">token</span></div> | ||
|
||
|
||
<div class="viewcode-block" id="CliUser.get_token_keyring"> | ||
<a class="viewcode-back" href="../../../api/sxapi.cli.html#sxapi.cli.cli_user.CliUser.get_token_keyring">[docs]</a> | ||
<span class="nd">@staticmethod</span> | ||
<span class="k">def</span> <span class="nf">get_token_keyring</span><span class="p">():</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> Gets the token stored in the keyring.</span> | ||
<span class="sd"> """</span> | ||
<span class="k">return</span> <span class="n">keyring</span><span class="o">.</span><span class="n">get_password</span><span class="p">(</span><span class="s2">"sxapi"</span><span class="p">,</span> <span class="s2">"SMAXTEC_API_ACCESS_TOKEN"</span><span class="p">)</span></div> | ||
|
||
|
||
<div class="viewcode-block" id="CliUser.clear_token_keyring"> | ||
<a class="viewcode-back" href="../../../api/sxapi.cli.html#sxapi.cli.cli_user.CliUser.clear_token_keyring">[docs]</a> | ||
<span class="nd">@staticmethod</span> | ||
<span class="k">def</span> <span class="nf">clear_token_keyring</span><span class="p">():</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> Deletes the token from the keyring.</span> | ||
<span class="sd"> """</span> | ||
<span class="n">keyring</span><span class="o">.</span><span class="n">delete_password</span><span class="p">(</span><span class="s2">"sxapi"</span><span class="p">,</span> <span class="s2">"SMAXTEC_API_ACCESS_TOKEN"</span><span class="p">)</span></div> | ||
|
||
|
||
<span class="c1"># general functions</span> | ||
<div class="viewcode-block" id="CliUser.check_credentials_set"> | ||
<a class="viewcode-back" href="../../../api/sxapi.cli.html#sxapi.cli.cli_user.CliUser.check_credentials_set">[docs]</a> | ||
<span class="k">def</span> <span class="nf">check_credentials_set</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> Checks if token is already set.</span> | ||
<span class="sd"> """</span> | ||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">api_access_token</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="k">return</span> <span class="kc">True</span> | ||
<span class="k">return</span> <span class="kc">False</span></div> | ||
|
||
|
||
<div class="viewcode-block" id="CliUser.init_user"> | ||
<a class="viewcode-back" href="../../../api/sxapi.cli.html#sxapi.cli.cli_user.CliUser.init_user">[docs]</a> | ||
<span class="k">def</span> <span class="nf">init_user</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">config_dict</span><span class="p">,</span> <span class="n">args_token</span><span class="p">,</span> <span class="n">args_keyring</span><span class="p">):</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> This function retrieves the token from the specified resource</span> | ||
<span class="sd"> (keyring, environment or args) and initializes clients</span> | ||
<span class="sd"> of the supported APIs (PublicV2, IntegrationV2).</span> | ||
|
||
<span class="sd"> If no token can be found the token is retrieved via</span> | ||
<span class="sd"> the username and password.</span> | ||
|
||
<span class="sd"> If username and password are also missing, no credentials get</span> | ||
<span class="sd"> stored and not API clients are created.</span> | ||
<span class="sd"> """</span> | ||
<span class="k">if</span> <span class="n">args_token</span><span class="p">:</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">api_access_token</span> <span class="o">=</span> <span class="n">args_token</span> | ||
<span class="k">elif</span> <span class="n">args_keyring</span><span class="p">:</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">api_access_token</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_token_keyring</span><span class="p">()</span> | ||
<span class="k">else</span><span class="p">:</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">api_access_token</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_token_environment</span><span class="p">()</span> | ||
|
||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">api_access_token</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">config_dict</span><span class="p">[</span><span class="s2">"user"</span><span class="p">]</span> <span class="ow">and</span> <span class="n">config_dict</span><span class="p">[</span><span class="s2">"pwd"</span><span class="p">]:</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">public_v2_api</span> <span class="o">=</span> <span class="n">PublicAPIV2</span><span class="p">(</span> | ||
<span class="n">base_url</span><span class="o">=</span><span class="n">config_dict</span><span class="p">[</span><span class="s2">"api_public_v2_path"</span><span class="p">],</span> | ||
<span class="n">email</span><span class="o">=</span><span class="n">config_dict</span><span class="p">[</span><span class="s2">"user"</span><span class="p">],</span> | ||
<span class="n">password</span><span class="o">=</span><span class="n">config_dict</span><span class="p">[</span><span class="s2">"pwd"</span><span class="p">],</span> | ||
<span class="p">)</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">integration_v2_api</span> <span class="o">=</span> <span class="n">IntegrationAPIV2</span><span class="p">(</span> | ||
<span class="n">base_url</span><span class="o">=</span><span class="n">config_dict</span><span class="p">[</span><span class="s2">"api_integration_v2_path"</span><span class="p">],</span> | ||
<span class="n">email</span><span class="o">=</span><span class="n">config_dict</span><span class="p">[</span><span class="s2">"user"</span><span class="p">],</span> | ||
<span class="n">password</span><span class="o">=</span><span class="n">config_dict</span><span class="p">[</span><span class="s2">"pwd"</span><span class="p">],</span> | ||
<span class="p">)</span> | ||
|
||
<span class="bp">self</span><span class="o">.</span><span class="n">api_access_token</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">public_v2_api</span><span class="o">.</span><span class="n">get_token</span><span class="p">()</span> | ||
|
||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">api_access_token</span><span class="p">:</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">public_v2_api</span> <span class="o">=</span> <span class="n">PublicAPIV2</span><span class="p">(</span> | ||
<span class="n">base_url</span><span class="o">=</span><span class="n">config_dict</span><span class="p">[</span><span class="s2">"api_public_v2_path"</span><span class="p">],</span> | ||
<span class="n">api_token</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">api_access_token</span><span class="p">,</span> | ||
<span class="p">)</span> | ||
|
||
<span class="bp">self</span><span class="o">.</span><span class="n">integration_v2_api</span> <span class="o">=</span> <span class="n">IntegrationAPIV2</span><span class="p">(</span> | ||
<span class="n">base_url</span><span class="o">=</span><span class="n">config_dict</span><span class="p">[</span><span class="s2">"api_integration_v2_path"</span><span class="p">],</span> | ||
<span class="n">api_token</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">api_access_token</span><span class="p">,</span> | ||
<span class="p">)</span></div> | ||
</div> | ||
|
||
</pre></div> | ||
|
||
</div> | ||
|
||
</div> | ||
</div> | ||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation"> | ||
<div class="sphinxsidebarwrapper"> | ||
<h1 class="logo"><a href="../../../index.html">sxapi</a></h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h3>Navigation</h3> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../../../readme.html">Overview</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../../contributing.html">Contributions & Help</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../../license.html">License</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../../authors.html">Authors</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../../changelog.html">Changelog</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../../api/modules.html">Module Reference</a></li> | ||
</ul> | ||
|
||
<div class="relations"> | ||
<h3>Related Topics</h3> | ||
<ul> | ||
<li><a href="../../../index.html">Documentation overview</a><ul> | ||
<li><a href="../../index.html">Module code</a><ul> | ||
</ul></li> | ||
</ul></li> | ||
</ul> | ||
</div> | ||
<div id="searchbox" style="display: none" role="search"> | ||
<h3 id="searchlabel">Quick search</h3> | ||
<div class="searchformwrapper"> | ||
<form class="search" action="../../../search.html" method="get"> | ||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> | ||
<input type="submit" value="Go" /> | ||
</form> | ||
</div> | ||
</div> | ||
<script>document.getElementById('searchbox').style.display = "block"</script> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</div> | ||
</div> | ||
<div class="clearer"></div> | ||
</div> | ||
<div class="footer"> | ||
©2021, Florian Klien. | ||
|
||
| | ||
Powered by <a href="http://sphinx-doc.org/">Sphinx 7.2.6</a> | ||
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a> | ||
|
||
</div> | ||
|
||
|
||
|
||
|
||
</body> | ||
</html> |
Oops, something went wrong.