diff --git a/README.md b/README.md
index 07b9446..334a5de 100644
--- a/README.md
+++ b/README.md
@@ -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)
@@ -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`)
+### [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.
+
### [CoOrgIdentityLink API](https://spaces.at.internet2.edu/display/COmanage/CoOrgIdentityLink+API) (COmanage v4.0.0+)
- `coorg_identity_links_add() -> dict`
diff --git a/comanage_api/__init__.py b/comanage_api/__init__.py
index 39118f1..f6af7d3 100644
--- a/comanage_api/__init__.py
+++ b/comanage_api/__init__.py
@@ -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, \
@@ -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)
diff --git a/comanage_api/_cogroup.py b/comanage_api/_cogroup.py
new file mode 100644
index 0000000..7b944d3
--- /dev/null
+++ b/comanage_api/_cogroup.py
@@ -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":"",
+ "Name":"",
+ "Description":"",
+ "Open":true|false,
+ "Status":("Active"|"Suspended"),
+ "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()
diff --git a/examples/README.md b/examples/README.md
index 39c6d61..8d0bd81 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -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
@@ -61,6 +62,45 @@ api = ComanageApi(
)
```
+## 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
+
+```
+
## CoOrgIdentityLink API
Example: `co_org_identity_links_example.py`
diff --git a/examples/cogroup_example.py b/examples/cogroup_example.py
new file mode 100644
index 0000000..212c78a
--- /dev/null
+++ b/examples/cogroup_example.py
@@ -0,0 +1,103 @@
+# examples/cogroup_example.py
+# CoGroup API examples
+
+import os
+import sys
+
+sys.path.append(
+ os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
+)
+from examples 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
+
+# cogroup_add() -> dict
+print('### cogroup_add')
+try:
+ new_cogroup = api.cogroup_add()
+ print(json.dumps(new_cogroup, indent=4))
+except HTTPError as err:
+ print('[ERROR] Exception caught')
+ print('--> ', type(err).__name__, '-', err)
+
+# cogroup_delete() -> bool
+print('### cogroup_delete')
+try:
+ delete_cogroup = api.cogroup_delete()
+ print(json.dumps(delete_cogroup, indent=4))
+except HTTPError as err:
+ print('[ERROR] Exception caught')
+ print('--> ', type(err).__name__, '-', err)
+
+# cogroup_edit() -> bool
+print('### cogroup_edit')
+try:
+ edit_cogroup = api.cogroup_edit()
+ print(json.dumps(edit_cogroup, indent=4))
+except HTTPError as err:
+ print('[ERROR] Exception caught')
+ print('--> ', type(err).__name__, '-', err)
+
+# cogroup_reconcile_all() -> bool
+print('### cogroup_reconcile_all')
+try:
+ reconcile_all_cogroup = api.cogroup_reconcile_all()
+ print(json.dumps(reconcile_all_cogroup, indent=4))
+except HTTPError as err:
+ print('[ERROR] Exception caught')
+ print('--> ', type(err).__name__, '-', err)
+
+# cogroup_reconcile_one() -> bool
+print('### cogroup_reconcile_one')
+try:
+ reconcile_one_cogroup = api.cogroup_reconcile_one()
+ print(json.dumps(reconcile_one_cogroup, indent=4))
+except (TypeError, HTTPError) as err:
+ print('[ERROR] Exception caught')
+ print('--> ', type(err).__name__, '-', err)
+
+# cogroup_view_all() -> dict
+print('### cogroup_view_all')
+try:
+ all_cogroup = api.cogroup_view_all()
+ print(json.dumps(all_cogroup, indent=4))
+except (TypeError, HTTPError) as err:
+ print('[ERROR] Exception caught')
+ print('--> ', type(err).__name__, '-', err)
+
+# cogroup_view_per_co() -> dict
+print('### cogroup_view_per_co')
+try:
+ per_co_cogroup = api.cogroup_view_per_co()
+ print(json.dumps(per_co_cogroup, indent=4))
+except (TypeError, HTTPError) as err:
+ print('[ERROR] Exception caught')
+ print('--> ', type(err).__name__, '-', err)
+
+# cogroup_view_per_coperson() -> dict
+print('### cogroup_view_per_coperson')
+try:
+ per_coperson_cogroup = api.cogroup_view_per_coperson()
+ print(json.dumps(per_coperson_cogroup, indent=4))
+except (TypeError, HTTPError) as err:
+ print('[ERROR] Exception caught')
+ print('--> ', type(err).__name__, '-', err)
+
+# cogroup_view_per_identifier() -> dict
+print('### cogroup_view_per_identifier')
+try:
+ per_identfier_cogroup = api.cogroup_view_per_identifier()
+ print(json.dumps(per_identfier_cogroup, indent=4))
+except (TypeError, HTTPError) as err:
+ print('[ERROR] Exception caught')
+ print('--> ', type(err).__name__, '-', err)
+
+# cogroup_view_one() -> dict
+print('### cogroup_view_one')
+try:
+ one_cogroup = api.cogroup_view_one()
+ print(json.dumps(one_cogroup, indent=4))
+except (TypeError, HTTPError) as err:
+ print('[ERROR] Exception caught')
+ print('--> ', type(err).__name__, '-', err)