Skip to content

Commit f2c31bd

Browse files
authored
Merge pull request Clever#48 from Clever/swaggered
Swagger-codegen library
2 parents a754b29 + bd0a422 commit f2c31bd

File tree

322 files changed

+33038
-1388
lines changed

Some content is hidden

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

322 files changed

+33038
-1388
lines changed

.gitignore

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,68 @@
1-
*~
2-
*.pyc
3-
clever.egg-info
4-
dist
5-
build
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
venv/
48+
.python-version
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
57+
# Sphinx documentation
58+
docs/_build/
59+
60+
# PyBuilder
61+
target/
62+
63+
#Ipython Notebook
64+
.ipynb_checkpoints
65+
66+
.travis.yml
67+
git_push.sh
68+
.swagger-codegen/

.swagger-codegen-ignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Swagger Codegen Ignore
2+
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
24+
.gitignore

MANIFEST.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.PHONY: all test override deps publish
2+
SHELL := /bin/bash
3+
4+
all: deps test
5+
6+
deps:
7+
pip install -r requirements.txt
8+
9+
test:
10+
python -m unittest discover test
11+
12+
override:
13+
./override/override.sh
14+
15+
publish:
16+
./publish.sh

README.md

Lines changed: 38 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# Clever Python bindings
1+
# Clever - the Python library for the Clever API
22

3-
## Maintenance
3+
## API Documentation
4+
View more detailed documentation [here](docs/README.md)
45

5-
Clever is moving to a community supported model with our client libraries. We will still respond to and merge incoming PRs but are looking to turn over ownership of these libraries to the community. If you are interested, please contact our partner-engineering team at tech-support@clever.com.
6+
## Requirements.
67

7-
## Installation
8+
Python 2.7 and 3.4+
89

10+
## Installation
911
From PyPi:
1012

1113
```bash
@@ -24,97 +26,66 @@ Or from source:
2426
$ python setup.py install
2527
```
2628

27-
## Usage
28-
29-
Get started by importing the `clever` module and setting your authentication method:
30-
29+
Then import the package:
3130
```python
32-
import clever
33-
clever.set_token('YOUR_OAUTH_TOKEN')
31+
import clever
3432
```
3533

36-
The `clever` module exposes classes corresponding to resources:
34+
## Getting Started
3735

38-
* Contact
39-
* District
40-
* DistrictAdmin
41-
* School
42-
* SchoolAdmin
43-
* Section
44-
* Student
45-
* Teacher
46-
* Event
47-
48-
Each exposes a class method `all` that returns a list of all data in that resource that you have access to. Keyword arguments correspond to the same query parameters supported in the HTTP API, except that `limit` and `page` are not supported (pagination is handled automatically).
36+
Please follow the [installation procedure](#installation) and then run the following:
4937

5038
```python
51-
schools = clever.School.all() # gets information about all schools you have access to
52-
schools = clever.School.all(where=json.dumps({'name': 'Of Hard Knocks'}))
53-
schools = clever.School.all(sort='state')
54-
```
39+
from __future__ import print_function
40+
import time
41+
import clever
42+
from clever.rest import ApiException
43+
from pprint import pprint
44+
45+
# Note: This is hard coded for demo purposes only. Keep your access tokens secret!
46+
# https://dev.clever.com/docs/security#section-security-best-practices
47+
clever.configuration.access_token = 'TEST_TOKEN'
48+
# create an instance of the API class
49+
api_instance = clever.DataApi()
50+
51+
try:
52+
api_response = api_instance.get_students()
53+
for student in api_response.data:
54+
pprint(student.data.id)
55+
except ApiException as e:
56+
print("Exception when calling DataApi->get_students: %s\n" % e)
5557

56-
If you'd like more control over pagination, or to limit the number of resources returned, use the `iter` class method:
57-
58-
```python
59-
students = clever.Student.iter()
60-
for i in range(0,2000):
61-
print students.next()
6258
```
6359

64-
You may also use the `starting_after` or `ending_before` parameters with the `iter` method:
60+
## Updating the Library
6561

66-
```python
67-
students = clever.Student.iter(starting_after="530e5960049e75a9262cff1d")
68-
for s in students:
69-
print students.next()
70-
```
62+
1. Git clone swagger-codegen (https://github.com/swagger-api/swagger-codegen)
7163

72-
The `retrieve` class method takes in a Clever ID and returns a specific resource. The object (or list of objects in the case of `all`) supports accessing properties using either dot notation or dictionary notation:
64+
2. Git clone Clever's swagger-api repo (https://github.com/Clever/swagger-api)
7365

74-
```python
75-
demo_school = clever.School.retrieve("4fee004cca2e43cf27000001")
76-
assert demo_school.name == 'Clever Academy'
77-
assert demo_school['name'] == 'Clever Academy'
66+
3. Run this command in the swagger-codegen repo
7867
```
79-
80-
## CLI
81-
82-
The library comes with a basic command-line interface:
83-
84-
```bash
85-
$ export CLEVER_API_TOKEN=DEMO_TOKEN
86-
$ clever districts all
87-
Running the equivalent of:
88-
--
89-
curl https://api.clever.com/v1.1/districts -H "Authorization: Bearer DEMO_TOKEN"
90-
--
91-
Starting new HTTPS connection (1): api.clever.com
92-
API request to https://api.clever.com/v1.1/districts returned (response code, response body) of (200, '{"data":[{"data":{"name":"Demo District","id":"4fd43cc56d11340000000005"},"uri":"/v1.1/districts/4fd43cc56d11340000000005"}],"links":[{"rel":"self","uri":"/v1.1/districts"}]}')
93-
Result (HTTP status code 200):
94-
--
95-
{"data":[{"data":{"name":"Demo District","id":"4fd43cc56d11340000000005"},"uri":"/v1.1/districts/4fd43cc56d11340000000005"}],"links":[{"rel":"self","uri":"/v1.1/districts"}]}
96-
--
68+
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i $PATH_TO_SWAGGER_API_REPO/v1.2-client.yml -c $PATH_TO_THIS_REPO/override/config.json -l python -o $PATH_TO_THIS_REPO --additional-properties packageVersion=$VERSION
9769
```
9870

99-
Run `clever -h` to see a full list of commands.
71+
4. Run `make override` to copy over the override files
10072

101-
## Feedback
73+
5. Update the CHANGELOG.md with the changes!
10274

103-
Questions, feature requests, or feedback of any kind is always welcome! We're available at [tech-support@clever.com](mailto:tech-support@clever.com).
10475

10576
## Development
10677

10778
### Dependencies
10879

109-
pip install -r requirements.txt
80+
make deps
11081

11182
### Testing
11283

113-
python -m unittest discover test
84+
make test
11485

11586
## Publishing
11687

117-
Update VERSION and CHANGELOG.md and run `publish.sh` to publish a new version of the library.
88+
Run `make publish` to publish a new version of the library.
11889

11990
In order to publish to PyPI you will need a `.pypirc` file in your `$HOME` directory with the following contents:
12091
```

0 commit comments

Comments
 (0)