diff --git a/examples/client_secret_auth.ipynb b/examples/client_secret_auth.ipynb index 7224fa4..e302715 100644 --- a/examples/client_secret_auth.ipynb +++ b/examples/client_secret_auth.ipynb @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -38,7 +38,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -58,7 +58,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -67,7 +67,7 @@ "timeseries_id3 = \"52a61a83-e2db-49b4-be41-ef873a5a6192\"\n", "\n", "timeseries_name1 = \"13F-PI___011T\"\n", - "timeseries_facility1 = \"SNA\"\n", + "facility = \"SNA\"\n", "\n", "startTime1=\"2024-12-09T14:00:00.000Z\"\n", "endTime1=\"2024-12-09T15:00:01.000Z\"\n", @@ -84,55 +84,9 @@ }, { "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'data': {'items': [{'id': '1e95b249-5f3f-4b9e-ace1-d6e582897ff0',\n", - " 'name': 'Omnia IIoT write test',\n", - " 'description': 'test patch again 7',\n", - " 'step': False,\n", - " 'unit': None,\n", - " 'standardUnit': None,\n", - " 'assetId': None,\n", - " 'facility': '1190',\n", - " 'externalId': None,\n", - " 'source': 'IMS',\n", - " 'changedTime': '2023-06-29T05:58:52.3600000Z',\n", - " 'createdTime': '2021-04-29T05:12:12.8290000Z'},\n", - " {'id': '96236c02-4ca9-43bc-b8f2-427aa2545811',\n", - " 'name': 'Omnia IIoT write test2',\n", - " 'description': None,\n", - " 'step': False,\n", - " 'unit': None,\n", - " 'standardUnit': None,\n", - " 'assetId': None,\n", - " 'facility': '1131',\n", - " 'externalId': None,\n", - " 'source': 'IMS',\n", - " 'changedTime': '2023-10-05T12:25:26.3650000Z',\n", - " 'createdTime': '2023-10-05T12:25:26.3650000Z'},\n", - " {'id': 'fe8d8cc9-972c-4802-866f-a10e839d2429',\n", - " 'name': 'Omnia IIoT write test2',\n", - " 'description': None,\n", - " 'step': False,\n", - " 'unit': None,\n", - " 'standardUnit': None,\n", - " 'assetId': None,\n", - " 'facility': 'ASGA',\n", - " 'externalId': None,\n", - " 'source': 'IMS',\n", - " 'changedTime': '2023-10-05T08:33:39.0240000Z',\n", - " 'createdTime': '2023-10-05T08:33:39.0240000Z'}]}}" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "api.search_timeseries(name=\"*Omnia IIoT write test*\",limit=10)" ] @@ -182,7 +136,6 @@ "metadata": {}, "outputs": [], "source": [ - "#timeseries_id = os.environ[\"OMNIA_TIMESERIES_ID\"]\n", "api.get_history(id=timeseries_id1)" ] }, @@ -215,7 +168,6 @@ "metadata": {}, "outputs": [], "source": [ - "#timeseries_id = os.environ[\"OMNIA_TIMESERIES_ID\"]\n", "api.get_latest_datapoint(id=timeseries_id1)" ] }, @@ -232,9 +184,7 @@ "metadata": {}, "outputs": [], "source": [ - "timeseries_name = timeseries_name1 #os.environ[\"OMNIA_TIMESERIES_FEDERATION_NAME\"]\n", - "timeseries_facility = timeseries_facility1 #os.environ[\"OMNIA_TIMESERIES_FEDERATION_FACILITY\"]\n", - "api.get_datapoints_by_name(timeseries_name, timeseries_facility, startTime=startTime1, endTime=endTime1)" + "api.get_datapoints_by_name(timeseries_name1, facility, startTime=startTime1, endTime=endTime1)" ] }, { @@ -250,7 +200,6 @@ "metadata": {}, "outputs": [], "source": [ - "#timeseries_id = os.environ[\"OMNIA_TIMESERIES_FEDERATION_ID\"]\n", "api.get_datapoints(id=timeseries_id1, startTime=startTime1, endTime=endTime1, federationSource=federationSource[0])" ] }, @@ -267,7 +216,6 @@ "metadata": {}, "outputs": [], "source": [ - "#timeseries_id = os.environ[\"OMNIA_TIMESERIES_FEDERATION_ID\"]\n", "api.get_datapoints(id=timeseries_id3, startTime=startTime1, endTime=endTime1, federationSource=federationSource[2])" ] }, @@ -431,7 +379,7 @@ "api.post_timeseries(\n", " {\n", " \"name\":'Omnia IIoT write test python sdk',\n", - " \"facility\":\"ASGA\" \n", + " \"facility\":facility \n", " }\n", ")\n" ] @@ -452,8 +400,8 @@ "\n", "api.get_or_add_timeseries([\n", " {\n", - " \"name\":'Omnia IIoT write test python sdk 2',\n", - " \"facility\":\"ASGA\" \n", + " \"name\":'Omnia IIoT write test python sdk 3',\n", + " \"facility\":facility \n", " }\n", "])" ] @@ -487,7 +435,7 @@ "metadata": {}, "outputs": [], "source": [ - "api.patch_timeseries(id=\"Timeseries_ID\", request= \n", + "api.patch_timeseries(id=\"Timeseries_ID_to_update\", request= \n", " {\n", " \"name\":\"New name\",\n", " \"description\":\"Description of the tag\",\n", @@ -513,7 +461,7 @@ "api.put_timeseries(id=\"Timeseries_ID_to_update\", request= \n", " {\n", " \"name\":\"New name\",\n", - " \"facility\":\"ASGA\"\n", + " \"facility\":facility\n", " }\n", ")" ] @@ -533,11 +481,19 @@ "source": [ "api.write_data(id=\"Timeseries_ID_to_update\", data=\n", "{\n", - " \"datapoints\":[{\n", - " \"time\": \"2024-12-09T14:00:00.000Z\",\n", - " \"value\":10.3,\n", - " \"status\":192\n", - "}]\n", + " \"datapoints\":\n", + " [\n", + " {\n", + " \"time\": \"2024-12-02T14:00:00.000Z\",\n", + " \"value\":10.3,\n", + " \"status\":192\n", + " },\n", + " {\n", + " \"time\": \"2024-12-03T14:00:00.000Z\",\n", + " \"value\":10.4,\n", + " \"status\":192\n", + " }\n", + " ]\n", "})" ] }, @@ -555,15 +511,19 @@ "outputs": [], "source": [ "#this is not working\n", - "api.write_multiple(items=\n", - "[{\n", - " \"id\":\"b6610f13-0081-4d85-a0f0-699ee51bb4ca\",\n", - " \"datapoints\":[{\n", - " \"time\": \"2024-12-10T14:00:00.000Z\",\n", - " \"value\":10.4,\n", - " \"status\":192\n", - " }]\n", - "}])" + "api.write_multiple(items=[\n", + " {\n", + " \"id\":\"Timeseries_ID_to_update\",\n", + " \"datapoints\":\n", + " [\n", + " {\n", + " \"time\": \"2024-12-10T14:00:00.000Z\",\n", + " \"value\":10.4,\n", + " \"status\":192\n", + " }\n", + " ]\n", + " }\n", + "])" ] }, { @@ -575,65 +535,10 @@ }, { "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'data': {'items': [{'facility': 'ASGA', 'count': 25964},\n", - " {'facility': 'JSV', 'count': 25020},\n", - " {'facility': 'SFC', 'count': 25001},\n", - " {'facility': 'SFB', 'count': 25000},\n", - " {'facility': 'GKR', 'count': 24632},\n", - " {'facility': 'SFA', 'count': 17480},\n", - " {'facility': 'AHA', 'count': 16355},\n", - " {'facility': 'KVB', 'count': 14029},\n", - " {'facility': 'VAL', 'count': 10746},\n", - " {'facility': 'MAR', 'count': 8780},\n", - " {'facility': 'TROL', 'count': 1227},\n", - " {'facility': 'SLA', 'count': 364},\n", - " {'facility': 'ASGB', 'count': 330},\n", - " {'facility': 'GRA', 'count': 97},\n", - " {'facility': 'GFC', 'count': 58},\n", - " {'facility': 'JCA', 'count': 50},\n", - " {'facility': 'SNA', 'count': 49},\n", - " {'facility': 'KRIS', 'count': 32},\n", - " {'facility': 'TROB', 'count': 31},\n", - " {'facility': 'VIS', 'count': 26},\n", - " {'facility': 'NOR', 'count': 18},\n", - " {'facility': 'TROC', 'count': 17},\n", - " {'facility': 'DRA', 'count': 11},\n", - " {'facility': 'NJA', 'count': 11},\n", - " {'facility': 'SNB', 'count': 10},\n", - " {'facility': 'GFA', 'count': 9},\n", - " {'facility': 'GDR', 'count': 6},\n", - " {'facility': 'KAA', 'count': 6},\n", - " {'facility': 'HD', 'count': 5},\n", - " {'facility': 'TROA', 'count': 5},\n", - " {'facility': 'OSA', 'count': 4},\n", - " {'facility': 'OSC', 'count': 3},\n", - " {'facility': 'PERA', 'count': 3},\n", - " {'facility': 'PERB', 'count': 3},\n", - " {'facility': 'DOW', 'count': 2},\n", - " {'facility': 'MON', 'count': 2},\n", - " {'facility': 'OSE', 'count': 2},\n", - " {'facility': 'BAC', 'count': 1},\n", - " {'facility': 'GFB', 'count': 1},\n", - " {'facility': 'KLAB', 'count': 1},\n", - " {'facility': 'MLA', 'count': 1},\n", - " {'facility': 'OSS', 'count': 1},\n", - " {'facility': 'SNO', 'count': 1},\n", - " {'facility': 'VFR', 'count': 1}]}}" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#TEST\n", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "api.get_facilities()" ] }, @@ -646,27 +551,10 @@ }, { "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'data': {'items': [{'source': 'IMS', 'count': 195160},\n", - " {'source': 'FUGRO', 'count': 222},\n", - " {'source': 'IOC', 'count': 7},\n", - " {'source': 'INTEGRATIONTESTREADWRITE', 'count': 4},\n", - " {'source': 'NES', 'count': 1},\n", - " {'source': 'PENNTEST', 'count': 1}]}}" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#TEST\n", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "api.get_sources()" ] }, @@ -679,64 +567,28 @@ }, { "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'data': {'items': [{'facility': 'ASGA', 'count': 25961},\n", - " {'facility': 'JSV', 'count': 25020},\n", - " {'facility': 'SFC', 'count': 25001},\n", - " {'facility': 'SFB', 'count': 25000},\n", - " {'facility': 'GKR', 'count': 24632},\n", - " {'facility': 'SFA', 'count': 17459},\n", - " {'facility': 'AHA', 'count': 16355},\n", - " {'facility': 'KVB', 'count': 14029},\n", - " {'facility': 'VAL', 'count': 10746},\n", - " {'facility': 'MAR', 'count': 8780},\n", - " {'facility': 'TROL', 'count': 1225},\n", - " {'facility': 'SLA', 'count': 364},\n", - " {'facility': 'ASGB', 'count': 325},\n", - " {'facility': 'GRA', 'count': 93},\n", - " {'facility': 'JCA', 'count': 50},\n", - " {'facility': 'SNA', 'count': 27},\n", - " {'facility': 'NJA', 'count': 11},\n", - " {'facility': 'SNB', 'count': 10},\n", - " {'facility': 'GFA', 'count': 9},\n", - " {'facility': 'KRIS', 'count': 7},\n", - " {'facility': 'GDR', 'count': 6},\n", - " {'facility': 'KAA', 'count': 6},\n", - " {'facility': 'HD', 'count': 5},\n", - " {'facility': 'VIS', 'count': 5},\n", - " {'facility': 'OSA', 'count': 4},\n", - " {'facility': 'TROA', 'count': 4},\n", - " {'facility': 'GFC', 'count': 3},\n", - " {'facility': 'OSC', 'count': 3},\n", - " {'facility': 'PERA', 'count': 3},\n", - " {'facility': 'PERB', 'count': 3},\n", - " {'facility': 'MON', 'count': 2},\n", - " {'facility': 'NOR', 'count': 2},\n", - " {'facility': 'OSE', 'count': 2},\n", - " {'facility': 'BAC', 'count': 1},\n", - " {'facility': 'DOW', 'count': 1},\n", - " {'facility': 'GFB', 'count': 1},\n", - " {'facility': 'KLAB', 'count': 1},\n", - " {'facility': 'MLA', 'count': 1},\n", - " {'facility': 'OSS', 'count': 1},\n", - " {'facility': 'SNO', 'count': 1},\n", - " {'facility': 'VFR', 'count': 1}]}}" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#TEST\n", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "api.get_facilities_by_source(source=federationSource[0])" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Get source by facility" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "api.get_sources_by_facility(facility=facility)" + ] } ], "metadata": {