mirror of
https://github.com/vmware/vsphere-automation-sdk-python.git
synced 2024-11-23 01:49:59 -05:00
9505b5a261
Signed-off-by: Gordon Good <ggood@vmware.com>
279 lines
12 KiB
HTML
279 lines
12 KiB
HTML
|
||
|
||
<!DOCTYPE html>
|
||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||
<head>
|
||
<meta charset="utf-8">
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<title>Interface definition language to python mapping for enumerated types — NSX-T Policy SDK 2.3.0.0.2 documentation</title>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
|
||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||
<link rel="index" title="Index" href="genindex.html" />
|
||
<link rel="search" title="Search" href="search.html" />
|
||
|
||
|
||
<script src="_static/js/modernizr.min.js"></script>
|
||
|
||
</head>
|
||
|
||
<body class="wy-body-for-nav">
|
||
|
||
|
||
<div class="wy-grid-for-nav">
|
||
|
||
|
||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||
<div class="wy-side-scroll">
|
||
<div class="wy-side-nav-search">
|
||
|
||
|
||
|
||
<a href="index.html" class="icon icon-home"> NSX-T Policy SDK
|
||
|
||
|
||
|
||
</a>
|
||
|
||
|
||
|
||
|
||
<div class="version">
|
||
2.3.0.0.2
|
||
</div>
|
||
|
||
|
||
|
||
|
||
<div role="search">
|
||
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
|
||
<input type="text" name="q" placeholder="Search docs" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<p class="caption"><span class="caption-text">Contents:</span></p>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="com.html">com package</a></li>
|
||
</ul>
|
||
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||
|
||
|
||
<nav class="wy-nav-top" aria-label="top navigation">
|
||
|
||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||
<a href="index.html">NSX-T Policy SDK</a>
|
||
|
||
</nav>
|
||
|
||
|
||
<div class="wy-nav-content">
|
||
|
||
<div class="rst-content">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||
|
||
<ul class="wy-breadcrumbs">
|
||
|
||
<li><a href="index.html">Docs</a> »</li>
|
||
|
||
<li>Interface definition language to python mapping for enumerated types</li>
|
||
|
||
|
||
<li class="wy-breadcrumbs-aside">
|
||
|
||
|
||
<a href="_sources/enumeration.rst.txt" rel="nofollow"> View page source</a>
|
||
|
||
|
||
</li>
|
||
|
||
</ul>
|
||
|
||
|
||
<hr/>
|
||
</div>
|
||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||
<div itemprop="articleBody">
|
||
|
||
<div class="section" id="interface-definition-language-to-python-mapping-for-enumerated-types">
|
||
<span id="enumeration-description"></span><h1>Interface definition language to python mapping for enumerated types<a class="headerlink" href="#interface-definition-language-to-python-mapping-for-enumerated-types" title="Permalink to this headline">¶</a></h1>
|
||
<p>The interface language definition type system includes enumerated types. Python
|
||
SDK supports both 2.x and 3.x versions of Python. Since Python 2.x does
|
||
not have first class support for enumerations, special classes are
|
||
generated to represent enumerated types from the interface definition
|
||
language. The special class contains class attributes which represent
|
||
the values of the enumerated type.</p>
|
||
<p>This documentation explains the following:</p>
|
||
<ul class="simple">
|
||
<li>How the class variables are defined in the module. This specifies the names that you can use in your program.</li>
|
||
<li>How you instantiate a class to use it for communication with future versions of the service.</li>
|
||
</ul>
|
||
<div class="section" id="example-of-an-enumerated-type-documentation">
|
||
<h2>Example of an enumerated type documentation<a class="headerlink" href="#example-of-an-enumerated-type-documentation" title="Permalink to this headline">¶</a></h2>
|
||
<dl class="docutils">
|
||
<dt><em>class</em> com.vmware.vapi.metadata_client. <strong>SourceType</strong> (string)</dt>
|
||
<dd><p class="first">Bases: vmware.vapi.bindings.enum.Enum</p>
|
||
<p>Metadata source type</p>
|
||
<div class="admonition note">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">This class represents an enumerated type in the interface language definition type system. The class contains class attributes which represent the values in the current version of the enumerated type. Newer versions of the enumerated type may contain new values. To use new values of the enumerated type in communication with a server that supports a newer version of the API, you instantiate this class. See <a class="reference internal" href="#enumeration-description"><span class="std std-ref">enumerated type description page</span></a>.</p>
|
||
</div>
|
||
<p><strong>Parameters</strong> : <strong>string</strong> (<code class="docutils literal notranslate"><span class="pre">str</span></code>) – String value for the SourceType instance.</p>
|
||
<dl class="last docutils">
|
||
<dt><strong>FILE</strong> = <em>SourceType(string=’FILE’)</em></dt>
|
||
<dd>If the source is backed by a file.</dd>
|
||
<dt><strong>REMOTE</strong> = <em>SourceType(string=’REMOTE’)</em></dt>
|
||
<dd>If the source is backed by a remote service.</dd>
|
||
</dl>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="section" id="code-examples">
|
||
<h2>Code Examples<a class="headerlink" href="#code-examples" title="Permalink to this headline">¶</a></h2>
|
||
<p>The enumerated type classes are defined in python modules that your code
|
||
imports. You can use these in your code.</p>
|
||
<ol class="arabic simple">
|
||
<li>If you want to pass an enumerated type value in a method to a server, specify the class variable of the enumerated type class.</li>
|
||
</ol>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># SourceType is an enumerated type</span>
|
||
<span class="kn">from</span> <span class="nn">com.vmware.vapi.metadata_client</span> <span class="kn">import</span> <span class="n">SourceType</span>
|
||
|
||
<span class="c1"># SourceType has two class attrites, SourceType.FILE and SourceType.REMOTE</span>
|
||
<span class="n">spec</span> <span class="o">=</span> <span class="n">Source</span><span class="o">.</span><span class="n">CreateSpec</span><span class="p">(</span><span class="nb">type</span><span class="o">=</span><span class="n">SourceType</span><span class="o">.</span><span class="n">FILE</span><span class="p">,</span> <span class="n">filepath</span><span class="o">=</span><span class="s1">'entity_metadata.json'</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s1">'Entity service'</span><span class="p">)</span>
|
||
<span class="n">source_svc</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="s1">'entity'</span><span class="p">,</span> <span class="n">spec</span><span class="o">=</span><span class="n">spec</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<ol class="arabic simple" start="2">
|
||
<li>When you receive an enumerated type value in the response from a server, allow for unknown enumerated type values.</li>
|
||
</ol>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># SourceType is an enumerated type</span>
|
||
<span class="kn">from</span> <span class="nn">com.vmware.vapi.metadata_client</span> <span class="kn">import</span> <span class="n">SourceType</span>
|
||
|
||
<span class="n">source_info</span> <span class="o">=</span> <span class="n">source_svc</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="s1">'entity'</span><span class="p">)</span>
|
||
<span class="k">if</span> <span class="p">(</span><span class="n">source_info</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="n">SourceType</span><span class="o">.</span><span class="n">FILE</span><span class="p">)</span> <span class="p">{</span>
|
||
<span class="k">print</span> <span class="s1">'Source is a file'</span>
|
||
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">source_info</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="n">SourceType</span><span class="o">.</span><span class="n">REMOTE</span><span class="p">)</span> <span class="p">{</span>
|
||
<span class="k">print</span> <span class="s1">'Source is a remote provider'</span>
|
||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
||
<span class="k">print</span> <span class="s1">'Unknown source type: </span><span class="si">%s</span><span class="s1">'</span> <span class="o">%</span> <span class="nb">str</span><span class="p">(</span><span class="n">source_info</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
|
||
<span class="p">}</span>
|
||
</pre></div>
|
||
</div>
|
||
<ol class="arabic simple" start="3">
|
||
<li>Sending a new enumerated type value to a server that has a newer version of the enumerated type.</li>
|
||
</ol>
|
||
<p>To use new values of the enumerated type in communication with a server that supports a newer version of the API, you instantiate the
|
||
enumerated type class.</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># If a newer version of SourceType has a new value FOLDER, FOLDER would be one</span>
|
||
<span class="c1"># of the class attributes for SourceType. In the older version, SourceType has</span>
|
||
<span class="c1"># only two class attributes, FILE and REMOTE</span>
|
||
<span class="kn">from</span> <span class="nn">com.vmware.vapi.metadata_client</span> <span class="kn">import</span> <span class="n">SourceType</span>
|
||
<span class="n">spec</span> <span class="o">=</span> <span class="n">Source</span><span class="o">.</span><span class="n">CreateSpec</span><span class="p">(</span><span class="nb">type</span><span class="o">=</span><span class="n">SourceType</span><span class="p">(</span><span class="s1">'FOLDER'</span><span class="p">),</span> <span class="n">filepath</span><span class="o">=</span><span class="s1">'entity_metadata'</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s1">'Entity service'</span><span class="p">)</span>
|
||
<span class="n">source_svc</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="s1">'entity'</span><span class="p">,</span> <span class="n">spec</span><span class="o">=</span><span class="n">spec</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<footer>
|
||
|
||
|
||
<hr/>
|
||
|
||
<div role="contentinfo">
|
||
<p>
|
||
© Copyright 2018, VMware, Inc.
|
||
|
||
</p>
|
||
</div>
|
||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||
|
||
</footer>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</section>
|
||
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></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/js/theme.js"></script>
|
||
|
||
<script type="text/javascript">
|
||
jQuery(function () {
|
||
SphinxRtdTheme.Navigation.enable(true);
|
||
});
|
||
</script>
|
||
|
||
</body>
|
||
</html> |