Rearrange docs.
This commit is contained in:
parent
b81e427b99
commit
d0cde0218c
32 changed files with 1827 additions and 62 deletions
306
docs/_build/html/docs/ec2_tut.html
vendored
Normal file
306
docs/_build/html/docs/ec2_tut.html
vendored
Normal file
|
|
@ -0,0 +1,306 @@
|
|||
|
||||
|
||||
<!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>Use Moto as EC2 backend — Moto 0.4.10 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../search.html"/>
|
||||
<link rel="top" title="Moto 0.4.10 documentation" href="../index.html"/>
|
||||
<link rel="prev" title="Moto APIs" href="moto_apis.html"/>
|
||||
|
||||
|
||||
<script src="../_static/js/modernizr.min.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<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"> Moto
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
0.4.10
|
||||
</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">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="getting_started.html">Getting Started with Moto</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="other_langs.html">Other languages</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="moto_apis.html">Moto APIs</a></li>
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Use Moto as EC2 backend</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#launching-instances">Launching instances</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../index.html">Moto</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>Use Moto as EC2 backend</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
<a href="../_sources/docs/ec2_tut.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="use-moto-as-ec2-backend">
|
||||
<span id="ec2-tut"></span><h1>Use Moto as EC2 backend<a class="headerlink" href="#use-moto-as-ec2-backend" title="Permalink to this headline">¶</a></h1>
|
||||
<p>This tutorial explains <code class="docutils literal"><span class="pre">moto.ec2</span></code>‘s features and how to use it. This
|
||||
tutorial assumes that you have already downloaded and installed boto and moto.
|
||||
Before all code examples the following snippet is launched:</p>
|
||||
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">boto.ec2</span><span class="o">,</span> <span class="nn">moto</span>
|
||||
<span class="gp">>>> </span><span class="n">mock_ec2</span> <span class="o">=</span> <span class="n">moto</span><span class="o">.</span><span class="n">mock_ec2</span><span class="p">()</span>
|
||||
<span class="gp">>>> </span><span class="n">mock_ec2</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
|
||||
<span class="gp">>>> </span><span class="n">conn</span> <span class="o">=</span> <span class="n">boto</span><span class="o">.</span><span class="n">ec2</span><span class="o">.</span><span class="n">connect_to_region</span><span class="p">(</span><span class="s2">"eu-west-1"</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="section" id="launching-instances">
|
||||
<h2>Launching instances<a class="headerlink" href="#launching-instances" title="Permalink to this headline">¶</a></h2>
|
||||
<p>After mock is started, the behavior is the same than previously:</p>
|
||||
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">reservation</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">run_instances</span><span class="p">(</span><span class="s1">'ami-f00ba4'</span><span class="p">)</span>
|
||||
<span class="gp">>>> </span><span class="n">reservation</span><span class="o">.</span><span class="n">instances</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="go">Instance:i-91dd2f32</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Moto set static or generate random object’s attributes:</p>
|
||||
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">vars</span><span class="p">(</span><span class="n">reservation</span><span class="o">.</span><span class="n">instances</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
|
||||
<span class="go">{'_in_monitoring_element': False,</span>
|
||||
<span class="go"> '_placement': None,</span>
|
||||
<span class="go"> '_previous_state': None,</span>
|
||||
<span class="go"> '_state': pending(0),</span>
|
||||
<span class="go"> 'ami_launch_index': u'0',</span>
|
||||
<span class="go"> 'architecture': u'x86_64',</span>
|
||||
<span class="go"> 'block_device_mapping': None,</span>
|
||||
<span class="go"> 'client_token': '',</span>
|
||||
<span class="go"> 'connection': EC2Connection:ec2.eu-west-1.amazonaws.com,</span>
|
||||
<span class="go"> 'dns_name': u'ec2-54.214.135.84.compute-1.amazonaws.com',</span>
|
||||
<span class="go"> 'ebs_optimized': False,</span>
|
||||
<span class="go"> 'eventsSet': None,</span>
|
||||
<span class="go"> 'group_name': None,</span>
|
||||
<span class="go"> 'groups': [],</span>
|
||||
<span class="go"> 'hypervisor': u'xen',</span>
|
||||
<span class="go"> 'id': u'i-91dd2f32',</span>
|
||||
<span class="go"> 'image_id': u'f00ba4',</span>
|
||||
<span class="go"> 'instance_profile': None,</span>
|
||||
<span class="go"> 'instance_type': u'm1.small',</span>
|
||||
<span class="go"> 'interfaces': [NetworkInterface:eni-ed65f870],</span>
|
||||
<span class="go"> 'ip_address': u'54.214.135.84',</span>
|
||||
<span class="go"> 'item': u'\n ',</span>
|
||||
<span class="go"> 'kernel': u'None',</span>
|
||||
<span class="go"> 'key_name': u'None',</span>
|
||||
<span class="go"> 'launch_time': u'2015-07-27T05:59:57Z',</span>
|
||||
<span class="go"> 'monitored': True,</span>
|
||||
<span class="go"> 'monitoring': u'\n ',</span>
|
||||
<span class="go"> 'monitoring_state': u'enabled',</span>
|
||||
<span class="go"> 'persistent': False,</span>
|
||||
<span class="go"> 'platform': None,</span>
|
||||
<span class="go"> 'private_dns_name': u'ip-10.136.187.180.ec2.internal',</span>
|
||||
<span class="go"> 'private_ip_address': u'10.136.187.180',</span>
|
||||
<span class="go"> 'product_codes': [],</span>
|
||||
<span class="go"> 'public_dns_name': u'ec2-54.214.135.84.compute-1.amazonaws.com',</span>
|
||||
<span class="go"> 'ramdisk': None,</span>
|
||||
<span class="go"> 'reason': '',</span>
|
||||
<span class="go"> 'region': RegionInfo:eu-west-1,</span>
|
||||
<span class="go"> 'requester_id': None,</span>
|
||||
<span class="go"> 'root_device_name': None,</span>
|
||||
<span class="go"> 'root_device_type': None,</span>
|
||||
<span class="go"> 'sourceDestCheck': u'true',</span>
|
||||
<span class="go"> 'spot_instance_request_id': None,</span>
|
||||
<span class="go"> 'state_reason': None,</span>
|
||||
<span class="go"> 'subnet_id': None,</span>
|
||||
<span class="go"> 'tags': {},</span>
|
||||
<span class="go"> 'virtualization_type': u'paravirtual',</span>
|
||||
<span class="go"> 'vpc_id': None}</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||
|
||||
|
||||
<a href="moto_apis.html" class="btn btn-neutral" title="Moto APIs" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Steve Pulec.
|
||||
|
||||
</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/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">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../',
|
||||
VERSION:'0.4.10',
|
||||
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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
343
docs/_build/html/docs/getting_started.html
vendored
Normal file
343
docs/_build/html/docs/getting_started.html
vendored
Normal file
|
|
@ -0,0 +1,343 @@
|
|||
|
||||
|
||||
<!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>Getting Started with Moto — Moto 0.4.10 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../search.html"/>
|
||||
<link rel="top" title="Moto 0.4.10 documentation" href="../index.html"/>
|
||||
<link rel="next" title="Moto APIs" href="moto_apis.html"/>
|
||||
<link rel="prev" title="Moto: Mock AWS Services" href="../index.html"/>
|
||||
|
||||
|
||||
<script src="../_static/js/modernizr.min.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<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"> Moto
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
0.4.10
|
||||
</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">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ul class="current">
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Getting Started with Moto</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#installing-moto">Installing Moto</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#moto-usage">Moto usage</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#decorator">Decorator</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#context-manager">Context manager</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#raw">Raw</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#stand-alone-server-mode">Stand-alone server mode</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="moto_apis.html">Moto APIs</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="ec2_tut.html">Use Moto as EC2 backend</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../index.html">Moto</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>Getting Started with Moto</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
<a href="../_sources/docs/getting_started.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="getting-started-with-moto">
|
||||
<span id="getting-started"></span><h1>Getting Started with Moto<a class="headerlink" href="#getting-started-with-moto" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="section" id="installing-moto">
|
||||
<h2>Installing Moto<a class="headerlink" href="#installing-moto" title="Permalink to this headline">¶</a></h2>
|
||||
<p>You can use <code class="docutils literal"><span class="pre">pip</span></code> to install the latest released version of <code class="docutils literal"><span class="pre">moto</span></code>:</p>
|
||||
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">moto</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>If you want to install <code class="docutils literal"><span class="pre">moto</span></code> from source:</p>
|
||||
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">git</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">spulec</span><span class="o">/</span><span class="n">moto</span><span class="o">.</span><span class="n">git</span>
|
||||
<span class="n">cd</span> <span class="n">moto</span>
|
||||
<span class="n">python</span> <span class="n">setup</span><span class="o">.</span><span class="n">py</span> <span class="n">install</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="moto-usage">
|
||||
<h2>Moto usage<a class="headerlink" href="#moto-usage" title="Permalink to this headline">¶</a></h2>
|
||||
<p>For example we have the following code we want to test:</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">boto</span>
|
||||
<span class="kn">from</span> <span class="nn">boto.s3.key</span> <span class="kn">import</span> <span class="n">Key</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">MyModel</span><span class="p">(</span><span class="nb">object</span><span class="p">):</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="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">value</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">save</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">conn</span> <span class="o">=</span> <span class="n">boto</span><span class="o">.</span><span class="n">connect_s3</span><span class="p">()</span>
|
||||
<span class="n">bucket</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">get_bucket</span><span class="p">(</span><span class="s1">'mybucket'</span><span class="p">)</span>
|
||||
<span class="n">k</span> <span class="o">=</span> <span class="n">Key</span><span class="p">(</span><span class="n">bucket</span><span class="p">)</span>
|
||||
<span class="n">k</span><span class="o">.</span><span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
|
||||
<span class="n">k</span><span class="o">.</span><span class="n">set_contents_from_string</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>There are several method to do this, just keep in mind Moto creates a full blank environment.</p>
|
||||
<div class="section" id="decorator">
|
||||
<h3>Decorator<a class="headerlink" href="#decorator" title="Permalink to this headline">¶</a></h3>
|
||||
<p>With a decorator wrapping all the calls to S3 are automatically mocked out.</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">boto</span>
|
||||
<span class="kn">from</span> <span class="nn">moto</span> <span class="kn">import</span> <span class="n">mock_s3</span>
|
||||
<span class="kn">from</span> <span class="nn">mymodule</span> <span class="kn">import</span> <span class="n">MyModel</span>
|
||||
|
||||
<span class="nd">@mock_s3</span>
|
||||
<span class="k">def</span> <span class="nf">test_my_model_save</span><span class="p">():</span>
|
||||
<span class="n">conn</span> <span class="o">=</span> <span class="n">boto</span><span class="o">.</span><span class="n">connect_s3</span><span class="p">()</span>
|
||||
<span class="c1"># We need to create the bucket since this is all in Moto's 'virtual' AWS account</span>
|
||||
<span class="n">conn</span><span class="o">.</span><span class="n">create_bucket</span><span class="p">(</span><span class="s1">'mybucket'</span><span class="p">)</span>
|
||||
|
||||
<span class="n">model_instance</span> <span class="o">=</span> <span class="n">MyModel</span><span class="p">(</span><span class="s1">'steve'</span><span class="p">,</span> <span class="s1">'is awesome'</span><span class="p">)</span>
|
||||
<span class="n">model_instance</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
|
||||
|
||||
<span class="k">assert</span> <span class="n">conn</span><span class="o">.</span><span class="n">get_bucket</span><span class="p">(</span><span class="s1">'mybucket'</span><span class="p">)</span><span class="o">.</span><span class="n">get_key</span><span class="p">(</span><span class="s1">'steve'</span><span class="p">)</span><span class="o">.</span><span class="n">get_contents_as_string</span><span class="p">()</span> <span class="o">==</span> <span class="s1">'is awesome'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="context-manager">
|
||||
<h3>Context manager<a class="headerlink" href="#context-manager" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Same as decorator, every call inside <code class="docutils literal"><span class="pre">with</span></code> statement are mocked out.</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">test_my_model_save</span><span class="p">():</span>
|
||||
<span class="k">with</span> <span class="n">mock_s3</span><span class="p">():</span>
|
||||
<span class="n">conn</span> <span class="o">=</span> <span class="n">boto</span><span class="o">.</span><span class="n">connect_s3</span><span class="p">()</span>
|
||||
<span class="n">conn</span><span class="o">.</span><span class="n">create_bucket</span><span class="p">(</span><span class="s1">'mybucket'</span><span class="p">)</span>
|
||||
|
||||
<span class="n">model_instance</span> <span class="o">=</span> <span class="n">MyModel</span><span class="p">(</span><span class="s1">'steve'</span><span class="p">,</span> <span class="s1">'is awesome'</span><span class="p">)</span>
|
||||
<span class="n">model_instance</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
|
||||
|
||||
<span class="k">assert</span> <span class="n">conn</span><span class="o">.</span><span class="n">get_bucket</span><span class="p">(</span><span class="s1">'mybucket'</span><span class="p">)</span><span class="o">.</span><span class="n">get_key</span><span class="p">(</span><span class="s1">'steve'</span><span class="p">)</span><span class="o">.</span><span class="n">get_contents_as_string</span><span class="p">()</span> <span class="o">==</span> <span class="s1">'is awesome'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="raw">
|
||||
<h3>Raw<a class="headerlink" href="#raw" title="Permalink to this headline">¶</a></h3>
|
||||
<p>You can also start and stop manually the mocking.</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">test_my_model_save</span><span class="p">():</span>
|
||||
<span class="n">mock</span> <span class="o">=</span> <span class="n">mock_s3</span><span class="p">()</span>
|
||||
<span class="n">mock</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
|
||||
|
||||
<span class="n">conn</span> <span class="o">=</span> <span class="n">boto</span><span class="o">.</span><span class="n">connect_s3</span><span class="p">()</span>
|
||||
<span class="n">conn</span><span class="o">.</span><span class="n">create_bucket</span><span class="p">(</span><span class="s1">'mybucket'</span><span class="p">)</span>
|
||||
|
||||
<span class="n">model_instance</span> <span class="o">=</span> <span class="n">MyModel</span><span class="p">(</span><span class="s1">'steve'</span><span class="p">,</span> <span class="s1">'is awesome'</span><span class="p">)</span>
|
||||
<span class="n">model_instance</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
|
||||
|
||||
<span class="k">assert</span> <span class="n">conn</span><span class="o">.</span><span class="n">get_bucket</span><span class="p">(</span><span class="s1">'mybucket'</span><span class="p">)</span><span class="o">.</span><span class="n">get_key</span><span class="p">(</span><span class="s1">'steve'</span><span class="p">)</span><span class="o">.</span><span class="n">get_contents_as_string</span><span class="p">()</span> <span class="o">==</span> <span class="s1">'is awesome'</span>
|
||||
|
||||
<span class="n">mock</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="stand-alone-server-mode">
|
||||
<h3>Stand-alone server mode<a class="headerlink" href="#stand-alone-server-mode" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Moto comes with a stand-alone server allowing you to mock out an AWS HTTP endpoint. It is very useful to test even if you don’t use Python.</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ moto_server ec2 -p3000
|
||||
* Running on http://127.0.0.1:3000/
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>This method isn’t encouraged if you’re using <code class="docutils literal"><span class="pre">boto</span></code>, best is to use decorator method.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||
|
||||
<a href="moto_apis.html" class="btn btn-neutral float-right" title="Moto APIs" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||
|
||||
|
||||
<a href="../index.html" class="btn btn-neutral" title="Moto: Mock AWS Services" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Steve Pulec.
|
||||
|
||||
</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/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">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../',
|
||||
VERSION:'0.4.10',
|
||||
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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
256
docs/_build/html/docs/moto_apis.html
vendored
Normal file
256
docs/_build/html/docs/moto_apis.html
vendored
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
|
||||
|
||||
<!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>Moto APIs — Moto 0.4.10 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../search.html"/>
|
||||
<link rel="top" title="Moto 0.4.10 documentation" href="../index.html"/>
|
||||
<link rel="next" title="Use Moto as EC2 backend" href="ec2_tut.html"/>
|
||||
<link rel="prev" title="Other languages" href="other_langs.html"/>
|
||||
|
||||
|
||||
<script src="../_static/js/modernizr.min.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<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"> Moto
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
0.4.10
|
||||
</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">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="getting_started.html">Getting Started with Moto</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="other_langs.html">Other languages</a></li>
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Moto APIs</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#reset-api">Reset API</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#dashboard">Dashboard</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="ec2_tut.html">Use Moto as EC2 backend</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../index.html">Moto</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>Moto APIs</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
<a href="../_sources/docs/moto_apis.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="moto-apis">
|
||||
<span id="id1"></span><h1>Moto APIs<a class="headerlink" href="#moto-apis" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Moto provides some internal APIs to view and change the state of the backends.</p>
|
||||
<div class="section" id="reset-api">
|
||||
<h2>Reset API<a class="headerlink" href="#reset-api" title="Permalink to this headline">¶</a></h2>
|
||||
<p>This API resets the state of all of the backends. Send an HTTP POST to reset:</p>
|
||||
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="s2">"http://motoapi.amazonaws.com/moto-api/reset"</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="dashboard">
|
||||
<h2>Dashboard<a class="headerlink" href="#dashboard" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Moto comes with a dashboard to view the current state of the system:</p>
|
||||
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">localhost</span><span class="p">:</span><span class="mi">5000</span><span class="o">/</span><span class="n">moto</span><span class="o">-</span><span class="n">api</span><span class="o">/</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||
|
||||
<a href="ec2_tut.html" class="btn btn-neutral float-right" title="Use Moto as EC2 backend" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||
|
||||
|
||||
<a href="other_langs.html" class="btn btn-neutral" title="Other languages" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Steve Pulec.
|
||||
|
||||
</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/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">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../',
|
||||
VERSION:'0.4.10',
|
||||
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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
243
docs/_build/html/docs/other_langs.html
vendored
Normal file
243
docs/_build/html/docs/other_langs.html
vendored
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
|
||||
|
||||
<!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>Other languages — Moto 0.4.10 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../search.html"/>
|
||||
<link rel="top" title="Moto 0.4.10 documentation" href="../index.html"/>
|
||||
<link rel="next" title="Moto APIs" href="moto_apis.html"/>
|
||||
<link rel="prev" title="Getting Started with Moto" href="getting_started.html"/>
|
||||
|
||||
|
||||
<script src="../_static/js/modernizr.min.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<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"> Moto
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
0.4.10
|
||||
</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">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="getting_started.html">Getting Started with Moto</a></li>
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Other languages</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="moto_apis.html">Moto APIs</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="ec2_tut.html">Use Moto as EC2 backend</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../index.html">Moto</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>Other languages</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
<a href="../_sources/docs/other_langs.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="other-languages">
|
||||
<span id="other-langs"></span><h1>Other languages<a class="headerlink" href="#other-languages" title="Permalink to this headline">¶</a></h1>
|
||||
<p>You don’t need to use Python to use Moto; it can be used with any language. To use it with another language, run moto_server. Here are some examples in other languages:</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="https://github.com/spulec/moto/blob/master/other_langs/sqsSample.java">Java</a></li>
|
||||
<li><a class="reference external" href="https://github.com/spulec/moto/blob/master/other_langs/test.rb">Ruby</a></li>
|
||||
<li><a class="reference external" href="https://github.com/spulec/moto/blob/master/other_langs/test.js">Javascript</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||
|
||||
<a href="moto_apis.html" class="btn btn-neutral float-right" title="Moto APIs" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||
|
||||
|
||||
<a href="getting_started.html" class="btn btn-neutral" title="Getting Started with Moto" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Steve Pulec.
|
||||
|
||||
</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/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">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../',
|
||||
VERSION:'0.4.10',
|
||||
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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
283
docs/_build/html/docs/server_mode.html
vendored
Normal file
283
docs/_build/html/docs/server_mode.html
vendored
Normal file
|
|
@ -0,0 +1,283 @@
|
|||
|
||||
|
||||
<!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>Server mode — Moto 0.4.10 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../search.html"/>
|
||||
<link rel="top" title="Moto 0.4.10 documentation" href="../index.html"/>
|
||||
<link rel="next" title="Moto APIs" href="moto_apis.html"/>
|
||||
<link rel="prev" title="Getting Started with Moto" href="getting_started.html"/>
|
||||
|
||||
|
||||
<script src="../_static/js/modernizr.min.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<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"> Moto
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
0.4.10
|
||||
</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">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="getting_started.html">Getting Started with Moto</a></li>
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Server mode</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#other-languages">Other languages</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="moto_apis.html">Moto APIs</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="ec2_tut.html">Use Moto as EC2 backend</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../index.html">Moto</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>Server mode</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
<a href="../_sources/docs/server_mode.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="server-mode">
|
||||
<span id="id1"></span><h1>Server mode<a class="headerlink" href="#server-mode" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Moto has a stand-alone server mode. This allows you to utilize
|
||||
the backend structure of Moto even if you don’t use Python.</p>
|
||||
<p>It uses flask, which isn’t a default dependency. You can install the
|
||||
server ‘extra’ package with:</p>
|
||||
<div class="code bash highlight-default"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">moto</span><span class="p">[</span><span class="n">server</span><span class="p">]</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>You can then start it running a service:</p>
|
||||
<div class="code bash highlight-default"><div class="highlight"><pre><span></span>$ moto_server ec2
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>You can also pass the port:</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ moto_server ec2 -p3000
|
||||
* Running on http://127.0.0.1:3000/
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>If you want to be able to use the server externally you can pass an IP
|
||||
address to bind to as a hostname or allow any of your external
|
||||
interfaces with 0.0.0.0:</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ moto_server ec2 -H <span class="m">0</span>.0.0.0
|
||||
* Running on http://0.0.0.0:5000/
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Please be aware this might allow other network users to access your
|
||||
server.</p>
|
||||
<p>Then go to <a class="reference external" href="http://localhost:5000/?Action=DescribeInstances">localhost</a> to see a list of running instances (it will be empty since you haven’t added any yet).</p>
|
||||
<p>If you want to use boto3 with this, you can pass an <cite>endpoint_url</cite> to the resource</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">boto3</span><span class="o">.</span><span class="n">resource</span><span class="p">(</span>
|
||||
<span class="n">service_name</span><span class="o">=</span><span class="s1">'s3'</span><span class="p">,</span>
|
||||
<span class="n">region_name</span><span class="o">=</span><span class="s1">'us-west-1'</span><span class="p">,</span>
|
||||
<span class="n">endpoint_url</span><span class="o">=</span><span class="s1">'http://localhost:5000'</span><span class="p">,</span>
|
||||
<span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="section" id="other-languages">
|
||||
<h2>Other languages<a class="headerlink" href="#other-languages" title="Permalink to this headline">¶</a></h2>
|
||||
<p>You don’t need to use Python to use Moto; it can be used with any language. Here are some examples to run it with other languages:</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="https://github.com/spulec/moto/blob/master/other_langs/sqsSample.java">Java</a></li>
|
||||
<li><a class="reference external" href="https://github.com/spulec/moto/blob/master/other_langs/test.rb">Ruby</a></li>
|
||||
<li><a class="reference external" href="https://github.com/spulec/moto/blob/master/other_langs/test.js">Javascript</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||
|
||||
<a href="moto_apis.html" class="btn btn-neutral float-right" title="Moto APIs" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||
|
||||
|
||||
<a href="getting_started.html" class="btn btn-neutral" title="Getting Started with Moto" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Steve Pulec.
|
||||
|
||||
</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/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">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../',
|
||||
VERSION:'0.4.10',
|
||||
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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue