Skip to content

Commit fb91b48

Browse files
authored
Merge pull request #4 from AltSchool/Clever-master
Fetch upstream changes
2 parents f72b7e4 + ab07bd7 commit fb91b48

File tree

326 files changed

+33121
-1435
lines changed

Some content is hidden

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

326 files changed

+33121
-1435
lines changed

.circleci/config.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 2
2+
jobs:
3+
build:
4+
working_directory: ~/Clever/clever-python
5+
docker:
6+
- image: circleci/python:2.7.15
7+
environment:
8+
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
9+
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
10+
steps:
11+
- run:
12+
command: cd $HOME && git clone --depth 1 -v https://github.com/Clever/ci-scripts.git && cd ci-scripts && git show --oneline -s
13+
name: Clone ci-scripts
14+
- checkout
15+
- setup_remote_docker
16+
- run:
17+
command: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
18+
name: Set up CircleCI artifacts directories
19+
- run: sudo pip install -r test-requirements.txt
20+
- run: sudo pip install -r requirements.txt
21+
- run: make test
22+
- run: $HOME/ci-scripts/circleci/report-card $RC_DOCKER_USER $RC_DOCKER_PASS "$RC_DOCKER_EMAIL" $RC_GITHUB_TOKEN

.drone.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.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

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
## 3.0.2 (2018-07-16)
2+
* Removes implicit relative imports which are not supported in Python 3
3+
4+
## 3.0.1 (2018-05-15)
5+
* Change students home_language 'Telegu' to 'Telugu'
6+
7+
## 3.0.0 (2018-01-02)
8+
* Use API v2.0, generated by swagger-codegen. This is a major, breaking change for the library.
9+
10+
## 2.4.0 (2017-09-18)
11+
* Use API v1.2
12+
13+
## 2.3.2 (2017-08-22)
14+
* Support unicode characters in API response
15+
16+
## 2.3.1 (2017-02-06)
17+
* Changed support email address
18+
19+
## 2.3.0 (2017-01-19)
20+
* Added bindings for Contact resource. [#41](https://github.com/Clever/clever-python/pull/41)
21+
* Updated CLI [#43](https://github.com/Clever/clever-python/pull/43)
22+
123
## 2.2.0 (2016-02-03)
224
* Added bindings for DistrictAdmin and SchoolAdmin resources. [#37](https://github.com/Clever/clever-python/pull/37)
325

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: 56 additions & 66 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 [email protected].
6+
## Requirements.
67

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

10+
## Installation
911
From PyPi:
1012

1113
```bash
@@ -24,92 +26,80 @@ 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')
34-
# or if you're using API key auth
35-
# clever.set_api_key('YOUR_API_KEY')
31+
import clever
3632
```
3733

38-
The `clever` module exposes classes corresponding to resources:
39-
40-
* Contact
41-
* District
42-
* DistrictAdmin
43-
* School
44-
* SchoolAdmin
45-
* Section
46-
* Student
47-
* Teacher
48-
* Event
34+
## Getting Started
4935

50-
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:
5137

5238
```python
53-
schools = clever.School.all() # gets information about all schools you have access to
54-
schools = clever.School.all(where=json.dumps({'name': 'Of Hard Knocks'}))
55-
schools = clever.School.all(sort='state')
56-
```
39+
from __future__ import print_function
40+
import time
41+
import clever
42+
from clever.rest import ApiException
43+
from pprint import pprint
5744

58-
If you'd like more control over pagination, or to limit the number of resources returned, use the `iter` class method:
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
5947

60-
```python
61-
students = clever.Student.iter()
62-
for i in range(0,2000):
63-
print students.next()
64-
```
65-
66-
You may also use the `starting_after` or `ending_before` parameters with the `iter` method:
48+
# Configure OAuth2 access token for authorization: oauth
49+
configuration = clever.Configuration()
50+
configuration.access_token = 'YOUR_ACCESS_TOKEN'
6751

68-
```python
69-
students = clever.Student.iter(starting_after="530e5960049e75a9262cff1d")
70-
for s in students:
71-
print students.next()
72-
```
52+
# create an instance of the API class
53+
api_instance = clever.DataApi(clever.ApiClient(configuration))
7354

74-
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:
55+
try:
56+
api_response = api_instance.get_students()
57+
for student in api_response.data:
58+
pprint(student.data.id)
59+
except ApiException as e:
60+
print("Exception when calling DataApi->get_students: %s\n" % e)
7561

76-
```python
77-
demo_school = clever.School.retrieve("4fee004cca2e43cf27000001")
78-
assert demo_school.name == 'Clever Academy'
79-
assert demo_school['name'] == 'Clever Academy'
8062
```
8163

82-
## CLI
64+
## Updating the Library
8365

84-
The library comes with a basic command-line interface:
66+
1. Git clone swagger-codegen (https://github.com/swagger-api/swagger-codegen)
8567

86-
```bash
87-
$ export CLEVER_API_KEY=DEMO_KEY
88-
$ clever districts all
89-
Running the equivalent of:
90-
--
91-
curl https://api.clever.com/v1.1/districts -H "Authorization: Basic REVNT19LRVk="
92-
--
93-
Starting new HTTPS connection (1): api.clever.com
94-
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"}]}')
95-
Result (HTTP status code 200):
96-
--
97-
{"data":[{"data":{"name":"Demo District","id":"4fd43cc56d11340000000005"},"uri":"/v1.1/districts/4fd43cc56d11340000000005"}],"links":[{"rel":"self","uri":"/v1.1/districts"}]}
98-
--
68+
2. Git clone Clever's swagger-api repo (https://github.com/Clever/swagger-api)
69+
70+
3. Run this command in the swagger-codegen repo
71+
```
72+
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i $PATH_TO_SWAGGER_API_REPO/v2.1-client.yml -l python -o $PATH_TO_THIS_REPO --additional-properties packageVersion=$VERSION
9973
```
10074

101-
Run `clever -h` to see a full list of commands.
75+
4. Run `make override` to copy over the override files
10276

103-
## Feedback
77+
5. Update the CHANGELOG.md with the changes!
10478

105-
Questions, feature requests, or feedback of any kind is always welcome! We're available at [[email protected]](mailto:[email protected]).
10679

10780
## Development
10881

10982
### Dependencies
11083

111-
pip install -r requirements.txt
84+
make deps
11285

11386
### Testing
11487

115-
python -m unittest discover test
88+
make test
89+
90+
## Publishing
91+
92+
Run `make publish` to publish a new version of the library.
93+
94+
In order to publish to PyPI you will need a `.pypirc` file in your `$HOME` directory with the following contents:
95+
```
96+
[distutils]
97+
index-servers =
98+
pypi
99+
100+
[pypi]
101+
username: ****
102+
password: ****
103+
```
104+
105+
The username and password are in 1Password for Teams under `PyPI`.

0 commit comments

Comments
 (0)