Skip to content

Commit

Permalink
Api V2 (#25)
Browse files Browse the repository at this point in the history
* Update docs

Get schedules working

Update example

Update to allow ToO deletes

Check minimal server version

Add image download

Cleanup

* Add targname

* Finalise new syntax

* Finish API upgrading

* Update tests

* Update tests
  • Loading branch information
robertdstein authored Feb 6, 2024
1 parent 27ae189 commit fe8f966
Show file tree
Hide file tree
Showing 20 changed files with 4,790 additions and 1,019 deletions.
663 changes: 0 additions & 663 deletions notebooks/1_too_models.ipynb

This file was deleted.

165 changes: 165 additions & 0 deletions notebooks/Example_1_Setting_Up_Credentials.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "3fb54b95",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import logging\n",
"from winterapi import WinterAPI\n",
"from winterapi.endpoints import BASE_URL"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "84869822",
"metadata": {},
"outputs": [],
"source": [
"logging.getLogger(\"winterapi\").setLevel(\"DEBUG\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "b7024bc4",
"metadata": {},
"outputs": [],
"source": [
"winter = WinterAPI()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "25197a54",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Using server http://winter.caltech.edu:82\n",
"Pinging server: True\n"
]
}
],
"source": [
"print(f\"Using server {BASE_URL}\") # Should show the URL of the API\n",
"print(f\"Pinging server: {winter.ping()}\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "88d1d907",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"User is [email protected]\n"
]
}
],
"source": [
"try:\n",
" print(f\"User is {winter.get_user()}\")\n",
"except KeyError:\n",
" print(\"No user credentials found. Please add these first!\")\n",
" winter.add_user_details(overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "f0dc0b3f",
"metadata": {},
"outputs": [],
"source": [
"# Uncomment to add new credentials\n",
"# winter.add_user_details(user=x, password=y, overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "64797375",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found the following saved programs: ['2024A001']\n"
]
}
],
"source": [
"print(f\"Found the following saved programs: {winter.get_programs()}\")\n",
"if len(winter.get_programs()) == 0:\n",
" print(\"No programs found. Add one to get started:\")\n",
" winter.add_program(overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "42f4d81b",
"metadata": {},
"outputs": [],
"source": [
"# Uncomment to add additional programs\n",
"winter.add_program(overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b16a0900",
"metadata": {},
"outputs": [],
"source": [
"# A fake local program I have created\n",
"winter.get_program_details(\"202XA000\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1023561f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "winterapi",
"language": "python",
"name": "winterapi"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit fe8f966

Please sign in to comment.