Skip to content

Commit

Permalink
Added error statuses to health endpoints
Browse files Browse the repository at this point in the history
Added documentation
  • Loading branch information
jamespeterschinner committed Dec 28, 2017
1 parent 48c729d commit d20c06c
Show file tree
Hide file tree
Showing 18 changed files with 191 additions and 9 deletions.
26 changes: 24 additions & 2 deletions async_v20/endpoints/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class GETServices(EndPoint):
# valid responses
responses = {200: {'services': ArrayService}}

# error msgs'
error = (404,)


class GETService(EndPoint):
host = HEALTH
Expand All @@ -30,6 +33,8 @@ class GETService(EndPoint):
# valid responses
responses = {200: Service}

# error msgs'
error = (404,)

class GETServiceLists(EndPoint):
host = HEALTH
Expand All @@ -43,6 +48,8 @@ class GETServiceLists(EndPoint):
# valid responses
responses = {200: {'lists': ArrayServiceList}}

# error msgs'
error = (404,)

class GETServiceList(EndPoint):
host = HEALTH
Expand All @@ -58,6 +65,8 @@ class GETServiceList(EndPoint):
# valid responses
responses = {200: {'lists': ServiceList}}

# error msgs'
error = (404,)

class GETEvents(EndPoint):
host = HEALTH
Expand All @@ -74,6 +83,8 @@ class GETEvents(EndPoint):
# valid responses
responses = {200: {'events': ArrayEvent}}

# error msgs'
error = (404,)

class GETCurrentEvent(EndPoint):
host = HEALTH
Expand All @@ -88,8 +99,10 @@ class GETCurrentEvent(EndPoint):
parameters = {ServiceID: (PATH, 'service-id')}

# valid responses
responses = {200: {'events': Event}}
responses = {200: Event}

# error msgs'
error = (404,)

class GETEvent(EndPoint):
host = HEALTH
Expand All @@ -105,8 +118,10 @@ class GETEvent(EndPoint):
EventSid: (PATH, 'event-sid')}

# valid responses
responses = {200: {'events': Event}}
responses = {200: Event}

# error msgs'
error = (404,)

class GETStatuses(EndPoint):
host = HEALTH
Expand All @@ -120,6 +135,8 @@ class GETStatuses(EndPoint):
# valid responses
responses = {200: {'statuses': ArrayStatus}}

# error msgs'
error = (404,)

class GETStatus(EndPoint):
host = HEALTH
Expand All @@ -136,6 +153,8 @@ class GETStatus(EndPoint):
# valid responses
responses = {200: Status}

# error msgs'
error = (404,)

class GETImages(EndPoint):
host = HEALTH
Expand All @@ -148,3 +167,6 @@ class GETImages(EndPoint):

# valid responses
responses = {200: {'images': ArrayImage}}

# error msgs'
error = (404,)
2 changes: 1 addition & 1 deletion async_v20/interface/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def _create_response(json_body, endpoint, schema, status, boolean, datetim
data.append((json_object, create_attribute(schema.get(json_object), json_field)))
else:
obj = schema(**json_body)
data = [(obj.__class__.__name__.lower(), obj)]
data = [(obj.__class__.__name__, obj)]
return Response(data, status, boolean, datetime_format)


Expand Down
Binary file modified doc/build/doctrees/api.doctree
Binary file not shown.
Binary file modified doc/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified doc/build/doctrees/index.doctree
Binary file not shown.
2 changes: 2 additions & 0 deletions doc/build/html/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ <h1>All modules for which code is available</h1>
<li><a href="async_v20/definitions/types.html">async_v20.definitions.types</a></li>
<li><a href="async_v20/endpoints/annotations.html">async_v20.endpoints.annotations</a></li>
<li><a href="async_v20/interface/account.html">async_v20.interface.account</a></li>
<li><a href="async_v20/interface/health.html">async_v20.interface.health</a></li>
<li><a href="async_v20/interface/instrument.html">async_v20.interface.instrument</a></li>
<li><a href="async_v20/interface/order.html">async_v20.interface.order</a></li>
<li><a href="async_v20/interface/position.html">async_v20.interface.position</a></li>
Expand Down Expand Up @@ -75,6 +76,7 @@ <h3>Navigation</h3>
<li class="toctree-l1"><a class="reference internal" href="../beyond_getting_started.html">Beyond Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../order_request_formatting.html">Formatting Order Requests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../datetimes.html">Dealing With Time</a></li>
<li class="toctree-l1"><a class="reference internal" href="../health.html">Health API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../traps.html">Traps for young players</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api.html">OandaClient API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../response.html">The Response Object</a></li>
Expand Down
18 changes: 17 additions & 1 deletion doc/build/html/_sources/api.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,20 @@ User
----

.. automethod:: async_v20.OandaClient.get_user_info
.. automethod:: async_v20.OandaClient.get_external_user_info
.. automethod:: async_v20.OandaClient.get_external_user_info

.. _health:

Health
------

.. automethod:: async_v20.OandaClient.get_current_event
.. automethod:: async_v20.OandaClient.get_event
.. automethod:: async_v20.OandaClient.get_service
.. automethod:: async_v20.OandaClient.get_service_list
.. automethod:: async_v20.OandaClient.get_status
.. automethod:: async_v20.OandaClient.list_events
.. automethod:: async_v20.OandaClient.list_images
.. automethod:: async_v20.OandaClient.list_service_lists
.. automethod:: async_v20.OandaClient.list_services
.. automethod:: async_v20.OandaClient.list_statuses
1 change: 1 addition & 0 deletions doc/build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Contents
beyond_getting_started
order_request_formatting
datetimes
health
traps
api
response
Expand Down
71 changes: 68 additions & 3 deletions doc/build/html/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
<span id="id1"></span><h2>OandaClient<a class="headerlink" href="#oandaclient" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="async_v20.OandaClient">
<em class="property">class </em><code class="descclassname">async_v20.</code><code class="descname">OandaClient</code><span class="sig-paren">(</span><em>token=None</em>, <em>account_id=None</em>, <em>format_order_requests=False</em>, <em>max_transaction_history=100</em>, <em>rest_host='api-fxpractice.oanda.com'</em>, <em>rest_port=443</em>, <em>rest_scheme='https'</em>, <em>stream_host='stream-fxpractice.oanda.com'</em>, <em>stream_port=None</em>, <em>stream_scheme='https'</em>, <em>datetime_format='UNIX'</em>, <em>rest_timeout=10</em>, <em>stream_timeout=60</em>, <em>max_requests_per_second=99</em>, <em>max_simultaneous_connections=10</em>, <em>loop=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/async_v20/client.html#OandaClient"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#async_v20.OandaClient" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.account.AccountInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.instrument.InstrumentInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.order.OrderInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.position.PositionInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.pricing.PricingInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.trade.TradeInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.transaction.TransactionInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.user.UserInterface</span></code></p>
<em class="property">class </em><code class="descclassname">async_v20.</code><code class="descname">OandaClient</code><span class="sig-paren">(</span><em>token=None</em>, <em>account_id=None</em>, <em>format_order_requests=False</em>, <em>max_transaction_history=100</em>, <em>rest_host='api-fxpractice.oanda.com'</em>, <em>rest_port=443</em>, <em>rest_scheme='https'</em>, <em>stream_host='stream-fxpractice.oanda.com'</em>, <em>stream_port=None</em>, <em>stream_scheme='https'</em>, <em>health_host='api-status.oanda.com'</em>, <em>health_port=80</em>, <em>health_scheme='http'</em>, <em>datetime_format='UNIX'</em>, <em>rest_timeout=10</em>, <em>stream_timeout=60</em>, <em>max_requests_per_second=99</em>, <em>max_simultaneous_connections=10</em>, <em>loop=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/async_v20/client.html#OandaClient"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#async_v20.OandaClient" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.account.AccountInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.instrument.InstrumentInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.order.OrderInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.position.PositionInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.pricing.PricingInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.trade.TradeInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.transaction.TransactionInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.user.UserInterface</span></code>, <code class="xref py py-class docutils literal"><span class="pre">async_v20.interface.health.HealthInterface</span></code></p>
<p>Create an API context for v20 access</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
Expand Down Expand Up @@ -271,7 +271,7 @@ <h2>Account<a class="headerlink" href="#account" title="Permalink to this headli
<h2>Instrument<a class="headerlink" href="#instrument" title="Permalink to this headline"></a></h2>
<dl class="method">
<dt id="async_v20.OandaClient.get_candles">
<code class="descclassname">OandaClient.</code><code class="descname">get_candles</code><span class="sig-paren">(</span><em>self</em>, <em>instrument: InstrumentName</em>, <em>price: PriceComponent=M</em>, <em>granularity: CandlestickGranularity=S5</em>, <em>count: Count=500</em>, <em>from_time: FromTime=Ellipsis</em>, <em>to_time: ToTime=Ellipsis</em>, <em>smooth: Smooth=False</em>, <em>include_first_query: IncludeFirstQuery=Ellipsis</em>, <em>daily_alignment: DailyAlignment=17</em>, <em>alignment_timezone: AlignmentTimezone=America/New_York</em>, <em>weekly_alignment: WeeklyAlignment=Friday</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.get_candles" title="Permalink to this definition"></a></dt>
<code class="descclassname">OandaClient.</code><code class="descname">get_candles</code><span class="sig-paren">(</span><em>self</em>, <em>instrument: InstrumentName</em>, <em>price: PriceComponent=M</em>, <em>granularity: CandlestickGranularity=S5</em>, <em>count: Count=Ellipsis</em>, <em>from_time: FromTime=Ellipsis</em>, <em>to_time: ToTime=Ellipsis</em>, <em>smooth: Smooth=False</em>, <em>include_first_query: IncludeFirstQuery=Ellipsis</em>, <em>daily_alignment: DailyAlignment=17</em>, <em>alignment_timezone: AlignmentTimezone=America/New_York</em>, <em>weekly_alignment: WeeklyAlignment=Friday</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.get_candles" title="Permalink to this definition"></a></dt>
<dd><p>Fetch candlestick data for an instrument.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
Expand Down Expand Up @@ -2445,6 +2445,69 @@ <h2>User<a class="headerlink" href="#user" title="Permalink to this headline">¶
</table>
</dd></dl>

</div>
<div class="section" id="health">
<span id="id3"></span><h2>Health<a class="headerlink" href="#health" title="Permalink to this headline"></a></h2>
<dl class="method">
<dt id="async_v20.OandaClient.get_current_event">
<code class="descclassname">OandaClient.</code><code class="descname">get_current_event</code><span class="sig-paren">(</span><em>self</em>, <em>service_id: ServiceID</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.get_current_event" title="Permalink to this definition"></a></dt>
<dd><p>Get the current event for a service</p>
</dd></dl>

<dl class="method">
<dt id="async_v20.OandaClient.get_event">
<code class="descclassname">OandaClient.</code><code class="descname">get_event</code><span class="sig-paren">(</span><em>self</em>, <em>service_id: ServiceID</em>, <em>event_sid: EventSid</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.get_event" title="Permalink to this definition"></a></dt>
<dd><p>Get an individual event</p>
</dd></dl>

<dl class="method">
<dt id="async_v20.OandaClient.get_service">
<code class="descclassname">OandaClient.</code><code class="descname">get_service</code><span class="sig-paren">(</span><em>self</em>, <em>service_id: ServiceID</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.get_service" title="Permalink to this definition"></a></dt>
<dd><p>Get a single service</p>
</dd></dl>

<dl class="method">
<dt id="async_v20.OandaClient.get_service_list">
<code class="descclassname">OandaClient.</code><code class="descname">get_service_list</code><span class="sig-paren">(</span><em>self</em>, <em>service_list_id: ServiceListID</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.get_service_list" title="Permalink to this definition"></a></dt>
<dd><p>Get a single service list</p>
</dd></dl>

<dl class="method">
<dt id="async_v20.OandaClient.get_status">
<code class="descclassname">OandaClient.</code><code class="descname">get_status</code><span class="sig-paren">(</span><em>self</em>, <em>status_id: StatusID</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.get_status" title="Permalink to this definition"></a></dt>
<dd><p>Get an individual status</p>
</dd></dl>

<dl class="method">
<dt id="async_v20.OandaClient.list_events">
<code class="descclassname">OandaClient.</code><code class="descname">list_events</code><span class="sig-paren">(</span><em>self</em>, <em>service_id: ServiceID</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.list_events" title="Permalink to this definition"></a></dt>
<dd><p>List all events for a service</p>
</dd></dl>

<dl class="method">
<dt id="async_v20.OandaClient.list_images">
<code class="descclassname">OandaClient.</code><code class="descname">list_images</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.list_images" title="Permalink to this definition"></a></dt>
<dd><p>List all status images</p>
</dd></dl>

<dl class="method">
<dt id="async_v20.OandaClient.list_service_lists">
<code class="descclassname">OandaClient.</code><code class="descname">list_service_lists</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.list_service_lists" title="Permalink to this definition"></a></dt>
<dd><p>List all service lists</p>
</dd></dl>

<dl class="method">
<dt id="async_v20.OandaClient.list_services">
<code class="descclassname">OandaClient.</code><code class="descname">list_services</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.list_services" title="Permalink to this definition"></a></dt>
<dd><p>List all the services</p>
</dd></dl>

<dl class="method">
<dt id="async_v20.OandaClient.list_statuses">
<code class="descclassname">OandaClient.</code><code class="descname">list_statuses</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#async_v20.OandaClient.list_statuses" title="Permalink to this definition"></a></dt>
<dd><p>List all statuses</p>
</dd></dl>

</div>
</div>

Expand All @@ -2470,6 +2533,7 @@ <h3>Navigation</h3>
<li class="toctree-l1"><a class="reference internal" href="beyond_getting_started.html">Beyond Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="order_request_formatting.html">Formatting Order Requests</a></li>
<li class="toctree-l1"><a class="reference internal" href="datetimes.html">Dealing With Time</a></li>
<li class="toctree-l1"><a class="reference internal" href="health.html">Health API</a></li>
<li class="toctree-l1"><a class="reference internal" href="traps.html">Traps for young players</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">OandaClient API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#oandaclient">OandaClient</a></li>
Expand All @@ -2481,6 +2545,7 @@ <h3>Navigation</h3>
<li class="toctree-l2"><a class="reference internal" href="#trade">Trade</a></li>
<li class="toctree-l2"><a class="reference internal" href="#transaction">Transaction</a></li>
<li class="toctree-l2"><a class="reference internal" href="#user">User</a></li>
<li class="toctree-l2"><a class="reference internal" href="#health">Health</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="response.html">The Response Object</a></li>
Expand Down

0 comments on commit d20c06c

Please sign in to comment.