Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Available at PyPi: [https://pypi.org/project/fabric-comanage-api/](https://pypi.

- [TL;DR](#tldr)
- [API endpoints](#endpoints)
- [CoGroup](#cogroup)
- [CoOrgIdentityLink](#coorgidentitylinks)
- [CoPerson](#coperson)
- [CoPersonRole](#copersonrole)
Expand Down Expand Up @@ -120,6 +121,38 @@ Return types based on implementation status of wrapped API endpoints
- `-> dict`: raise exception (`HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local`)
- `-> bool`: raise exception (`HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local`)

### <a name="cogroup"></a>[CoGroup API](https://spaces.at.internet2.edu/display/COmanage/CoGroup+API) (COmanage v4.0.0+)

- `cogroup_add() -> dict`
- `### NOT IMPLEMENTED ###`
- Add a new CoGroup.
- `cogroup_delete() -> bool`
- `### NOT IMPLEMENTED ###`
- Remove a CoGroup.
- `cogroup_edit() -> bool`
- `### NOT IMPLEMENTED ###`
- Edit an existing CoGroup.
- `cogroup_reconcile_all() -> bool`
- `### NOT IMPLEMENTED ###`
- Reconcile all membership groups.
- `cogroup_reconcile_one() -> bool`
- `### NOT IMPLEMENTED ###`
- Reconcile memberships for a CoGroup.
- `cogroup_view_all() -> dict`
- `### NOT IMPLEMENTED ###`
- Retrieve all existing CoGroups.
- `cogroup_view_per_co() -> dict`
- Retrieve CoGroups attached to a CO.
- `cogroup_view_per_coperson() -> dict`
- `### NOT IMPLEMENTED ###`
- Retrieve Groups attached to a CO Person.
- `cogroup_view_per_identifier() -> dict`
- `### NOT IMPLEMENTED ###`
- Retrieve all existing CO Groups attached to the specified identifier.
- `cogroup_view_one() -> dict`
- `### NOT IMPLEMENTED ###`
- Retrieve an existing CoGroup.

### <a name="coorgidentitylink"></a>[CoOrgIdentityLink API](https://spaces.at.internet2.edu/display/COmanage/CoOrgIdentityLink+API) (COmanage v4.0.0+)

- `coorg_identity_links_add() -> dict`
Expand Down
33 changes: 33 additions & 0 deletions comanage_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import requests_mock
from requests import Session

from ._cogroup import cogroup_add, cogroup_delete, cogroup_edit, cogroup_reconcile_all, cogroup_reconcile_one, \
cogroup_view_all, cogroup_view_per_co, cogroup_view_per_coperson, cogroup_view_per_identifier, cogroup_view_one
from ._coorgidentitylinks import coorg_identity_links_add, coorg_identity_links_delete, coorg_identity_links_edit, \
coorg_identity_links_view_all, coorg_identity_links_view_by_identity, coorg_identity_links_view_one
from ._copeople import copeople_add, copeople_delete, copeople_edit, copeople_find, copeople_match, \
Expand Down Expand Up @@ -92,6 +94,37 @@ def __init__(self, co_api_url: str, co_api_user: str, co_api_pass: str, co_api_o
self._s.headers = {'Content-Type': 'application/json'}
self._s.auth = (self._CO_API_USER, self._CO_API_PASS)

# CoGroup API
def cogroup_add(self):
return cogroup_add(self)

def cogroup_delete(self):
return cogroup_delete(self)

def cogroup_edit(self):
return cogroup_edit(self)

def cogroup_reconcile_all(self):
return cogroup_reconcile_all(self)

def cogroup_reconcile_one(self):
return cogroup_reconcile_one(self)

def cogroup_view_all(self):
return cogroup_view_all(self)

def cogroup_view_per_co(self):
return cogroup_view_per_co(self)

def cogroup_view_per_coperson(self):
return cogroup_view_per_coperson(self)

def cogroup_view_per_identifier(self):
return cogroup_view_per_identifier(self)

def cogroup_view_one(self):
return cogroup_view_one(self)

# CoOrgIdentityLink API
def coorg_identity_links_add(self):
return coorg_identity_links_add(self)
Expand Down
243 changes: 243 additions & 0 deletions comanage_api/_cogroup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
# comanage_api/_cogroup.py

"""
CoGroup API - https://spaces.at.internet2.edu/display/COmanage/CoGroup+API

Methods
-------
cogroup_add() -> dict
### NOT IMPLEMENTED ###
Add a new CoGroup.
cogroup_delete() -> bool
### NOT IMPLEMENTED ###
Remove a CoGroup.
cogroup_edit() -> bool
### NOT IMPLEMENTED ###
Edit an existing CoGroup.
cogroup_reconcile_all() -> bool
### NOT IMPLEMENTED ###
Reconcile all membership groups.
cogroup_reconcile_one() -> bool
### NOT IMPLEMENTED ###
Reconcile memberships for a CoGroup.
cogroup_view_all() -> dict
### NOT IMPLEMENTED ###
Retrieve all existing CoGroups.
cogroup_view_per_co() -> dict
Retrieve CoGroups attached to a CO.
cogroup_view_per_coperson() -> dict
### NOT IMPLEMENTED ###
Retrieve Groups attached to a CO Person.
cogroup_view_per_identifier() -> dict
### NOT IMPLEMENTED ###
Retrieve all existing CO Groups attached to the specified identifier.
cogroup_view_one() -> dict
### NOT IMPLEMENTED ###
Retrieve an existing CoGroup.
"""

import json

def cogroup_add(self) -> dict:
"""
### NOT IMPLEMENTED ###
Add a new CoGroup.

:param self:
:return
501 Server Error: Not Implemented for url: mock://not_implemented_501.local:
"""
url = self._MOCK_501_URL
resp = self._mock_session.get(
url=url
)
if resp.status_code == 200:
return json.loads(resp.text)
else:
resp.raise_for_status()

def cogroup_delete(self) -> bool:
"""
### NOT IMPLEMENTED ###
Remove a CoGroup.

:param self:
:return
501 Server Error: Not Implemented for url: mock://not_implemented_501.local:
"""
url = self._MOCK_501_URL
resp = self._mock_session.get(
url=url
)
if resp.status_code == 200:
return True
else:
resp.raise_for_status()

def cogroup_edit(self) -> bool:
"""
### NOT IMPLEMENTED ###
Edit an existing CoGroup.

:param self:
:return
501 Server Error: Not Implemented for url: mock://not_implemented_501.local:
"""
url = self._MOCK_501_URL
resp = self._mock_session.get(
url=url
)
if resp.status_code == 200:
return True
else:
resp.raise_for_status()

def cogroup_reconcile_all(self) -> bool:
"""
### NOT IMPLEMENTED ###
Reconcile all membership groups.

:param self:
:return
501 Server Error: Not Implemented for url: mock://not_implemented_501.local:
"""
url = self._MOCK_501_URL
resp = self._mock_session.get(
url=url
)
if resp.status_code == 200:
return True
else:
resp.raise_for_status()

def cogroup_reconcile_one(self) -> bool:
"""
### NOT IMPLEMENTED ###
Reconcile memberships for a CoGroup.

:param self:
:return
501 Server Error: Not Implemented for url: mock://not_implemented_501.local:
"""
url = self._MOCK_501_URL
resp = self._mock_session.get(
url=url
)
if resp.status_code == 200:
return True
else:
resp.raise_for_status()

def cogroup_view_all(self) -> dict:
"""
### NOT IMPLEMENTED ###
Retrieve all existing CoGroups.

:param self:
:return
501 Server Error: Not Implemented for url: mock://not_implemented_501.local:
"""
url = self._MOCK_501_URL
resp = self._mock_session.get(
url=url
)
if resp.status_code == 200:
return json.loads(resp.text)
else:
resp.raise_for_status()

def cogroup_view_per_co(self) -> dict:
"""
Retrieve CoGroups attached to a CO.

:param self:
:request
{
"RequestType":"CoGroups",
"Version":"1.0",
"CoGroups":
[
{
"Version":"1.0",
"CoId":"<CoID>",
"Name":"<Name>",
"Description":"<Description>",
"Open":true|false,
"Status":("Active"|"Suspended"),
"CouId":"<CouID>"
}
]
}:

Response Format
HTTP Status Response Body Description
200 OK CoGroup Response CoGroup returned
401 Unauthorized Authentication required
404 CO Unknown id not found
500 Other Error Unknown error
"""

url = self._CO_API_URL + '/co_groups.json'
params = {'coid': self._CO_API_ORG_ID}
resp = self._s.get(
url=url,
params=params
)
if resp.status_code == 200:
return json.loads(resp.text)

resp.raise_for_status()

def cogroup_view_per_coperson(self) -> dict:
"""
### NOT IMPLEMENTED ###
Retrieve Groups attached to a CO Person.

:param self:
:return
501 Server Error: Not Implemented for url: mock://not_implemented_501.local:
"""
url = self._MOCK_501_URL
resp = self._mock_session.get(
url=url
)
if resp.status_code == 200:
return json.loads(resp.text)
else:
resp.raise_for_status()

def cogroup_view_per_identifier(self) -> dict:
"""
### NOT IMPLEMENTED ###
Retrieve all existing CO Groups attached to the specified identifier.

:param self:
:return
501 Server Error: Not Implemented for url: mock://not_implemented_501.local:
"""
url = self._MOCK_501_URL
resp = self._mock_session.get(
url=url
)
if resp.status_code == 200:
return json.loads(resp.text)
else:
resp.raise_for_status()

def cogroup_view_one(self) -> dict:
"""
### NOT IMPLEMENTED ###
Retrieve an existing CoGroup.

:param self:
:return
501 Server Error: Not Implemented for url: mock://not_implemented_501.local:
"""
url = self._MOCK_501_URL
resp = self._mock_session.get(
url=url
)
if resp.status_code == 200:
return json.loads(resp.text)
else:
resp.raise_for_status()
40 changes: 40 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Examples demonstrating basic usage for each wrapped endpoint. Some of the values
## Table of Contents

- [Configuration](#config) `__init__.py` used by all examples
- [CoGroup API](#cogroup) example output
- [CoOrgIdentityLink API](#coorgidentitylink) example output
- [CoPerson API](#coperson) example output
- [CoPersonRole API](#copersonrole) example output
Expand Down Expand Up @@ -61,6 +62,45 @@ api = ComanageApi(
)
```

## <a name="cogroup"></a>CoGroup API

Example: `cogroup_example.py`

```console
$ python examples/cogroup_example.py
### cogroup_add
[ERROR] Exception caught
--> HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local
### cogroup_delete
[ERROR] Exception caught
--> HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local
### cogroup_edit
[ERROR] Exception caught
--> HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local
### cogroup_reconcile_all
[ERROR] Exception caught
--> HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local
### cogroup_reconcile_one
[ERROR] Exception caught
--> HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local
### cogroup_view_all
[ERROR] Exception caught
--> HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local
### cogroup_view_per_co
[ERROR] Exception caught
--> HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local
### cogroup_view_per_coperson
[ERROR] Exception caught
--> HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local
### cogroup_view_per_identifier
[ERROR] Exception caught
--> HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local
### cogroup_view_one
[ERROR] Exception caught
--> HTTPError - 501 Server Error: Not Implemented for url: mock://not_implemented_501.local

```

## <a name="coorgidentitylink"></a>CoOrgIdentityLink API

Example: `co_org_identity_links_example.py`
Expand Down
Loading