Skip to content

Commit 16ef993

Browse files
ChainReaction31ChainReaction31
authored andcommitted
deploy: fe704bb
0 parents  commit 16ef993

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+6187
-0
lines changed

.buildinfo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: 4a4f3fe1709d94529fc822bf7dc2d3bf
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7

.doctrees/environment.pickle

20.4 KB
Binary file not shown.

.doctrees/index.doctree

4.37 KB
Binary file not shown.

.doctrees/pydocs.doctree

2.72 KB
Binary file not shown.

.doctrees/tutorials.doctree

15.5 KB
Binary file not shown.

.nojekyll

Whitespace-only changes.

_sources/index.rst.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
ConSys4Py Documentation
3+
=====================================
4+
5+
.. toctree::
6+
:maxdepth: 2
7+
:caption: Contents:
8+
9+
tutorials
10+
pydocs
11+
12+
13+
14+
Indices and tables
15+
==================
16+
17+
* :ref:`genindex`
18+
* :ref:`modindex`
19+
* :ref:`search`

_sources/pydocs.rst.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ConSys4Py API Docs
2+
==================
3+
4+
.. automodule:: consys4py
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

_sources/tutorials.rst.txt

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
Tutorials
2+
====================
3+
4+
.. warning::
5+
6+
This is a work in progress, some features may change and packages may move or be removed
7+
before the 1.0 release.
8+
9+
Using the API
10+
============================
11+
There are three main ways to interact with the API
12+
13+
1. Direct API calls
14+
-----------------------------------------
15+
In the modules for parts 1 and 2, there are separate files that represent the different parts of the API. These files
16+
contain methods for interacting with the remote server directly.
17+
18+
2. Default API Helper
19+
-----------------------------------------
20+
Using the Default API helper allows for repeated calls to the same API server. This is useful when
21+
building a library on top of this project.
22+
23+
3. Custom API Requests
24+
-----------------------------------------
25+
If you need the most flexibility, you can create custom requests using the request builder and API helper objects
26+
27+
.. note::
28+
29+
The following examples will not convert the responses back into Objects, but it is possible to do so
30+
using the appropriate class's `model_validate` method on the response object's string representation.
31+
32+
Interacting with Systems
33+
============================
34+
35+
List Systems
36+
-----------------------------------------
37+
.. note::
38+
39+
Using a direct call from `Systems` file
40+
.. code-block:: python
41+
42+
from consys4py import Systems
43+
44+
Systems.list_all_systems(server_url)
45+
46+
Retrieve Specific System
47+
-----------------------------------------
48+
49+
.. code-block:: python
50+
51+
from consys4py import Systems
52+
53+
Systems.retrieve_system_by_id(server_url, system_id)
54+
55+
Add/Create System
56+
-----------------------------------------
57+
The method for creating a new system does take a string or properly structured `dict`.
58+
For ease of use, the `SmlJSONBody` or `GeoJSONBody` can be used. They use Pydantic to validate the data.
59+
Just be sure to convert them to a JSON string before passing them to the `create_new_systems` method.
60+
61+
.. code-block:: python
62+
63+
from consys4py import Systems
64+
65+
sml = SmlJSONBody(object_type='SimpleProcess', id=str(random.randint(1000, 9999)),
66+
description="A Test System inserted from the Python Connected Systems API Client",
67+
unique_id=f'urn:test:client:sml-single', label=f'Test System - SML Single',
68+
definition="http://test.com")
69+
70+
sml_as_str = sml.model_dump_json(exclude_none=True, by_alias=True)
71+
Systems.create_new_systems(server_url, sml_as_str, uname="test", pword="test",
72+
headers=sml_json_headers)
73+
74+
Datastreams and Observations
75+
============================
76+
77+
Add a Datastream and Observation
78+
------------------------------------------------------------
79+
.. note::
80+
81+
This assumes that the user knows the system id and the datastream id
82+
83+
.. code-block:: python
84+
85+
from consys4py import Datastreams
86+
87+
time_schema = TimeSchema(label="Test Datastream Time", definition="http://test.com/Time", name="timestamp",
88+
uom=URI(href="http://test.com/TimeUOM"))
89+
bool_schema = BooleanSchema(label="Test Datastream Boolean", definition="http://test.com/Boolean",
90+
name="testboolean")
91+
datarecord_schema = SWEDatastreamSchema(encoding=JSONEncoding(), obs_format=ObservationFormat.SWE_JSON.value,
92+
record_schema=DataRecordSchema(label="Test Datastream Record",
93+
definition="http://test.com/Record",
94+
fields=[time_schema, bool_schema]))
95+
96+
datastream_body = DatastreamBodyJSON(name="Test Datastream", output_name="Test Output #1", datastream_schema=datarecord_schema)
97+
temp_test_json = datastream_body.model_dump_json(exclude_none=True, by_alias=True)
98+
99+
resp = Datastreams.add_datastreams_to_system(server_url, retrieved_systems[1]['id'],
100+
datastream_body.model_dump_json(exclude_none=True, by_alias=True),
101+
headers=json_headers)
102+
103+
the_time = datetime.utcnow().isoformat() + 'Z'
104+
time_millis = test_time_start.timestamp() * 1000
105+
106+
obs = ObservationOMJSONInline(phenomenon_time=the_time,
107+
result_time=the_time,
108+
result={
109+
"timestamp": time_millis,
110+
"testboolean": True
111+
})
112+
print(f'Observation: {obs.model_dump_json(exclude_none=True, by_alias=True)}')
113+
resp = Observations.add_observations_to_datastream(server_url, ds_id,
114+
obs.model_dump_json(exclude_none=True, by_alias=True),
115+
headers=json_headers)
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/* Compatability shim for jQuery and underscores.js.
2+
*
3+
* Copyright Sphinx contributors
4+
* Released under the two clause BSD licence
5+
*/
6+
7+
/**
8+
* small helper function to urldecode strings
9+
*
10+
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL
11+
*/
12+
jQuery.urldecode = function(x) {
13+
if (!x) {
14+
return x
15+
}
16+
return decodeURIComponent(x.replace(/\+/g, ' '));
17+
};
18+
19+
/**
20+
* small helper function to urlencode strings
21+
*/
22+
jQuery.urlencode = encodeURIComponent;
23+
24+
/**
25+
* This function returns the parsed url parameters of the
26+
* current request. Multiple values per key are supported,
27+
* it will always return arrays of strings for the value parts.
28+
*/
29+
jQuery.getQueryParameters = function(s) {
30+
if (typeof s === 'undefined')
31+
s = document.location.search;
32+
var parts = s.substr(s.indexOf('?') + 1).split('&');
33+
var result = {};
34+
for (var i = 0; i < parts.length; i++) {
35+
var tmp = parts[i].split('=', 2);
36+
var key = jQuery.urldecode(tmp[0]);
37+
var value = jQuery.urldecode(tmp[1]);
38+
if (key in result)
39+
result[key].push(value);
40+
else
41+
result[key] = [value];
42+
}
43+
return result;
44+
};
45+
46+
/**
47+
* highlight a given string on a jquery object by wrapping it in
48+
* span elements with the given class name.
49+
*/
50+
jQuery.fn.highlightText = function(text, className) {
51+
function highlight(node, addItems) {
52+
if (node.nodeType === 3) {
53+
var val = node.nodeValue;
54+
var pos = val.toLowerCase().indexOf(text);
55+
if (pos >= 0 &&
56+
!jQuery(node.parentNode).hasClass(className) &&
57+
!jQuery(node.parentNode).hasClass("nohighlight")) {
58+
var span;
59+
var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg");
60+
if (isInSVG) {
61+
span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
62+
} else {
63+
span = document.createElement("span");
64+
span.className = className;
65+
}
66+
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
67+
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
68+
document.createTextNode(val.substr(pos + text.length)),
69+
node.nextSibling));
70+
node.nodeValue = val.substr(0, pos);
71+
if (isInSVG) {
72+
var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
73+
var bbox = node.parentElement.getBBox();
74+
rect.x.baseVal.value = bbox.x;
75+
rect.y.baseVal.value = bbox.y;
76+
rect.width.baseVal.value = bbox.width;
77+
rect.height.baseVal.value = bbox.height;
78+
rect.setAttribute('class', className);
79+
addItems.push({
80+
"parent": node.parentNode,
81+
"target": rect});
82+
}
83+
}
84+
}
85+
else if (!jQuery(node).is("button, select, textarea")) {
86+
jQuery.each(node.childNodes, function() {
87+
highlight(this, addItems);
88+
});
89+
}
90+
}
91+
var addItems = [];
92+
var result = this.each(function() {
93+
highlight(this, addItems);
94+
});
95+
for (var i = 0; i < addItems.length; ++i) {
96+
jQuery(addItems[i].parent).before(addItems[i].target);
97+
}
98+
return result;
99+
};
100+
101+
/*
102+
* backward compatibility for jQuery.browser
103+
* This will be supported until firefox bug is fixed.
104+
*/
105+
if (!jQuery.browser) {
106+
jQuery.uaMatch = function(ua) {
107+
ua = ua.toLowerCase();
108+
109+
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
110+
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
111+
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
112+
/(msie) ([\w.]+)/.exec(ua) ||
113+
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
114+
[];
115+
116+
return {
117+
browser: match[ 1 ] || "",
118+
version: match[ 2 ] || "0"
119+
};
120+
};
121+
jQuery.browser = {};
122+
jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true;
123+
}

0 commit comments

Comments
 (0)