-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create webqueue2api Package section and Getting Started docs
- Loading branch information
Showing
1 changed file
with
13 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,33 @@ | ||
# Getting Started | ||
|
||
The webqueue2api Package is the base of the [webqueue2 API](http://127.0.0.1:6061/ECN/webqueue2-api/api/Getting%20Started/). It consists of two primary parts: | ||
The webqueue2api Package provides both a parser to read data from ECN's queue and allow for programatic data access as well as an WSGI application to serve the webqueue2 API. | ||
|
||
- **Parser**: allows for the programtic access of data from the ECN queue system. | ||
- **API**: exposes a [WSGI](https://wsgi.readthedocs.io/en/latest/what.html) compliant RESTful API. | ||
The webqueue2api Package has the following structure: | ||
|
||
- `webqueue2api`: Contains global configuration and exports utilities/data classes. | ||
- `parser`: Contains classes for reading data from queue text files and making it available via objects. | ||
- `api`: Contains a WSGI application to host a RESTful API that relies on `parser`. | ||
|
||
## Basic Usage | ||
|
||
!!! example "Load a single Queue and show its Items." | ||
!!! example "Load a queue and get the number of items in it." | ||
```python | ||
import webqueue2api | ||
|
||
bidc_queue = webqueue2api.Queue("bidc") | ||
print(bidc_queue.items) | ||
ce_queue = webqueue2api.Queue("ce") | ||
print( len( ce_queue.items ) ) | ||
``` | ||
```python | ||
# Expected Output | ||
[ | ||
"[bidc2] (nvatkar) Re: Un-Domain PC setup," | ||
"[bidc4] (maswabey) Question re. Autodesk Fusion 360 upda...," | ||
"[bidc3] (dgmc) Move a managed PC onto self managed," | ||
"[bidc1] (nvatkar) BIDC iPad purchase and PAL access - m..." | ||
] | ||
29 | ||
``` | ||
|
||
!!! example "Load a single Item and see when it was last updated." | ||
!!! example "Load an item and get its subject." | ||
```python | ||
import webqueue2api | ||
|
||
ce_1 = webqueue2api.Item("ce", 1) | ||
print(ce_1.last_modified) | ||
``` | ||
```python | ||
# Expected Output | ||
"2021-06-04T11:01:00-0400" | ||
``` | ||
|
||
!!! example "Load all queues." | ||
```python | ||
import webqueue2api | ||
|
||
all_queues = webqueue2api.load_queues() | ||
|
||
# Print random Queue name | ||
print(all_queues[2].name) | ||
print( len( ce_1.subject ) ) | ||
``` | ||
```python | ||
# Expected Output | ||
"che" | ||
``` | ||
|
||
!!! example "See configuration settings." | ||
```python | ||
import webqueue2api | ||
|
||
# All configuration settings. | ||
print(webqueue2api.config.parser.queue_directory) | ||
``` | ||
```python | ||
# Expected Output: | ||
"/home/pier/e/queue/Mail" | ||
"Re: Battery Replacement" | ||
``` |