Skip to content

Commit e493bea

Browse files
author
Douglas Perrien Fenstermacher
committed
Adds support for Users, Calendars, Events, Calendar Groups, and Groups
1 parent 298e803 commit e493bea

File tree

12 files changed

+1884
-1
lines changed

12 files changed

+1884
-1
lines changed

.gitignore

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
.hypothesis/
51+
.pytest_cache/
52+
53+
# Translations
54+
*.mo
55+
*.pot
56+
57+
# Django stuff:
58+
*.log
59+
local_settings.py
60+
db.sqlite3
61+
db.sqlite3-journal
62+
63+
# Flask stuff:
64+
instance/
65+
.webassets-cache
66+
67+
# Scrapy stuff:
68+
.scrapy
69+
70+
# Sphinx documentation
71+
docs/_build/
72+
73+
# PyBuilder
74+
target/
75+
76+
# Jupyter Notebook
77+
.ipynb_checkpoints
78+
79+
# IPython
80+
profile_default/
81+
ipython_config.py
82+
83+
# pyenv
84+
.python-version
85+
86+
# pipenv
87+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
88+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
89+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
90+
# install all needed dependencies.
91+
#Pipfile.lock
92+
93+
# celery beat schedule file
94+
celerybeat-schedule
95+
96+
# SageMath parsed files
97+
*.sage.py
98+
99+
# Environments
100+
.env
101+
.venv
102+
env/
103+
venv/
104+
ENV/
105+
env.bak/
106+
venv.bak/
107+
108+
# Spyder project settings
109+
.spyderproject
110+
.spyproject
111+
112+
# Rope project settings
113+
.ropeproject
114+
115+
# mkdocs documentation
116+
/site
117+
118+
# mypy
119+
.mypy_cache/
120+
.dmypy.json
121+
dmypy.json
122+
123+
# Pyre type checker
124+
.pyre/
125+
126+
logging_config.json
127+
settings.py
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
To Request a Peer Review
2+
========================
3+
4+
- The title of the merge request should contain the ticket number and ticket description.
5+
- Provide a brief description of the package or change.
6+
- Upon submission, the label ~"Peer Review" will be applied.
7+
- Be sure to assign the merge request to the developer you would like to review your code.
8+
- This merge request should be from your feature branch to the master branch.
9+
- Complete the deployment for testing instructions with specific commands as needed.
10+
- You can delete from here up once you have completed the instructions above.
11+
12+
Description
13+
===========
14+
Provide a description of the change to the package here.
15+
16+
Deployment for Testing Instructions
17+
==================================
18+
```python
19+
python -m pip install --upgrade --user git+ssh://git@code.wm.edu/IT/software-systems/eispippackages/msgraph.git@test
20+
```
21+
22+
Peer Reviewer
23+
=============
24+
If you see any issues with the points below, submit as a conversation describing your concern. If this merge request proceeds after a discussion has begun, it must be marked "Resolved". After a positive peer review and all boxes are checked click the "Merge" button. After the merge completes successfully, re-assign to the developer.
25+
26+
* [ ] Structure
27+
- Package should follow a pattern of reasonable separation of purpose. Data and logs should not live with code.
28+
- Hardcoded values should be placed in external settings files (including email addresses) and referenced. The settings file should be ignored and in it's place a template_settings file should contain only non-secret information.
29+
- Avoid DB links and instead use instance specific database connections.
30+
31+
* [ ] Secrets
32+
- The package should not contain any keys, passwords or usernames.
33+
34+
* [ ] Sustainability
35+
- To the extent possible, the package should be able to be re-useable for multiple processes
36+
37+
* [ ] Good Practices
38+
- General code quality and good practices.
39+
- Code should contain a reasonable level of comments describing it's intended purpose/functionality.
40+
- Code should have a reasonable amount of exception handling and error logging for troubleshooting issues.
41+
- The package should contain a README.md file with information describing how to install and use the package.
42+
43+
* [ ] `setup.py`
44+
- Package version should be incremented to denote a new version/update to the package.
45+
- The package url should be up-to-date, denoting where the package can be currently found.
46+
47+
/label ~"Peer Review"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
To Request a Production Release
2+
===============================
3+
- The title line should contain the EIS ticket number and a description of the project or change.
4+
- Enter a description of the change below.
5+
- Complete the deployment to production instructions with specific commands as needed.
6+
- Look up the Feature -> Test merge request number and enter it next to the "!" below.
7+
- Enter a short description of how the change was tested.
8+
- Look up the production approval in the eis_change_management project under issues and enter the issue number next to the "#" below.
9+
- Upon submission the ~"Stage for Production" label will be applied.
10+
11+
Description
12+
===========
13+
Provide a description of the change to the package here.
14+
15+
Deployment to Production Instructions
16+
==================================
17+
```python
18+
python -m pip install --upgrade git+ssh://git@code.wm.edu/IT/software-systems/eispippackages/msgraph.git
19+
```
20+
21+
Approval
22+
========
23+
Approval == Close eis_change_management/eis_change_management#
24+
25+
Testing
26+
=======
27+
Feature -> Test Merge Request == !
28+
29+
Please provide a description of how this change was tested.
30+
31+
Rollback Plan
32+
=============
33+
Revert to the previous release.
34+
35+
Production Release Review
36+
=========================
37+
Please verify and check the box for each item below. If any items below are not satisfied, please comment below and submit as a discussion to the developer. If everything meets the requirements, merge and deploy.
38+
39+
* [ ] Ticket Number
40+
- Does the title of the merge request contain a ticket number?
41+
42+
* [ ] Production Approval
43+
- Does the request contain a production approval from a user or a qualified internal approver?
44+
45+
* [ ] Description
46+
- A description of the change has been included.
47+
48+
* [ ] Testing
49+
- Is the Feature -> Test Merge Request linked above?
50+
- Is a description of how the testing was performed included.
51+
52+
* [ ] Rollback Plan
53+
- Does the request contain a rollback plan.
54+
55+
56+
/label ~"Stage for Production"

README.md

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,79 @@
1-
# MSGraph
1+
# Microsoft Graph
2+
`msgraph` is a Python wrapper of the [Microsoft Graph](https://developer.microsoft.com/en-us/graph) API.
23

4+
5+
## Installation
6+
To install the `msgraph` library use the following command:
7+
```python
8+
python -m pip install git+ssh://git@code.wm.edu/IT/software-systems/eispippackages/msgraph.git
9+
```
10+
11+
## Usage
12+
13+
### Authenticating against the API
14+
The library currently support connecting to the API using an SSL certificate:
15+
```python
16+
from msgraph import api
17+
18+
authority_host_uri = 'https://login.microsoftonline.com'
19+
tenant = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
20+
resource_uri = 'https://graph.microsoft.com'
21+
client_id = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
22+
client_thumbprint = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
23+
client_certificate = ''
24+
api_instance = api.GraphAPI.from_certificate(authority_host_uri, tenant, resource_uri, client_id, client_certificate, client_thumbprint)
25+
```
26+
27+
### Using the API to fetch Users
28+
You can use the `msgraph.user` module to interact with `User` instances. `User` instanced can be fetched using the `msgraph.user.User` class:
29+
```python
30+
from msgraph import user
31+
all_users = user.User.get(api_instance)
32+
```
33+
34+
To fetch a specific user, you can also include the user's `User Principal Name`, which is the user's email address:
35+
```python
36+
dpfens_instance = user.User.get(api_instance, user='[email protected]')
37+
```
38+
39+
### Fetch a User's Calendars
40+
Now let's fetch the `Calendar`s of a particular user. To interact with a `Calendar`, `Event`, calendar `Group`, or calendar `Category` instance, we will use the `msgraph.calendar` module:
41+
```python
42+
from msgraph import calendar
43+
44+
dpfens_calendars = calendar.Calendar.get(api_instance, user=dpfens_instance)
45+
```
46+
47+
### Fetch a User's Events from a given Calendar
48+
Now let's fetch the `Event` instances from the main calendar of `dpfens`:
49+
```python
50+
calendar_lookup = dict()
51+
for calendar in dpfens_calendars:
52+
calendar_lookup[calendar.name] = calendar
53+
54+
primary_calendar = calendar_lookup['Calendar']
55+
dpfens_events = calendar.Event.get(dpfens_instance, calendar=primary_calendar)
56+
```
57+
58+
### Update an Event
59+
To update an `Event`, we can use the `Event.update` method:
60+
```python
61+
dpfens_event = dpfens_events[0]
62+
dpfens_event.subject = 'Important meeting'
63+
dpfens_event.update(api_instance)
64+
```
65+
Now the updates made to the `Event` object have been saved back to the `calendar` of `dpfens`.
66+
67+
### Delete an Event from a Calendar
68+
Let's try deleting an `Event` on a `Calendar` using the `Event.delete` method:
69+
```python
70+
dpfens_event = dpfens_events[0]
71+
dpfens_event.delete(api_instance)
72+
```
73+
After calling the `delete` method, the `Event` has been removed from the `calendar` of `dpfens`.
74+
75+
76+
## Logging
77+
The following modules have their own loggers:
78+
* `msgraph.api` - Used for logging error messages from the `API` and logging raw `HTTP` response content
79+
* `msgrpaph.calendar` - Used for logging the creation/update/deletes of `Calendar`/`Event`/`Group`/`Category` instances

msgraph/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)