https://github.com/uwrit/uwgs
Python3 Client Library for UW Groups API v3
https://github.com/uwrit/uwgs
python
Last synced: about 1 year ago
JSON representation
Python3 Client Library for UW Groups API v3
- Host: GitHub
- URL: https://github.com/uwrit/uwgs
- Owner: uwrit
- License: bsd-3-clause
- Created: 2019-06-03T21:10:03.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-25T20:07:24.000Z (almost 3 years ago)
- Last Synced: 2025-03-10T01:15:28.799Z (over 1 year ago)
- Topics: python
- Language: Python
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# uwgs [](https://travis-ci.com/uwrit/uwgs)
Python3 Client Library for UW Groups API v3
### Functionality
At the moment, this library provides read-only functionality for:
- [Get Group By Id](https://iam-tools.u.washington.edu/apis/gws/#/Groups/getGroup)
- [All Read Membership Endpoints (except history)](https://iam-tools.u.washington.edu/apis/gws/#/Membership)
- [Search](https://iam-tools.u.washington.edu/apis/gws/#/Searches/get_search)
```python
import uwgs
from collections import namedtuple
import os
import json
Config = namedtuple('Config', ['client_cert', 'client_key', 'url'])
def load_config():
cwd = os.path.dirname(os.path.abspath(__file__))
fp = os.path.join(cwd, 'uwgs.json')
with open(fp, 'r') as f:
data = json.load(f)
cfg = Config(data['client_cert'], data['client_key'], data['url'])
return cfg
def cli():
cfg = load_config()
client = uwgs.Client(cfg.client_cert, cfg.client_key, cfg.url)
payload = client.search(name='*')
if payload.ok:
groups = [group['id'] for group in payload.data['data']]
rosters = client.get_memberships(groups)
print(rosters)
if __name__ == "__main__":
cli()
```