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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ Return types based on implementation status of wrapped API endpoints

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

- `coorg_identity_links_add() -> dict`
- `### NOT IMPLEMENTED ###`
- `coorg_identity_links_add(coperson_id: int, org_identity_id: int) -> dict`
- Add a new CO Org Identity Link.
- A person must have an Org Identity and a CO Person record before they can be linked.
- Note that invitations are a separate operation.
Expand Down
4 changes: 2 additions & 2 deletions comanage_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def __init__(self, co_api_url: str, co_api_user: str, co_api_pass: str, co_api_o
self._s.auth = (self._CO_API_USER, self._CO_API_PASS)

# CoOrgIdentityLink API
def coorg_identity_links_add(self):
return coorg_identity_links_add(self)
def coorg_identity_links_add(self, coperson_id: int, org_identity_id: int):
return coorg_identity_links_add(self, coperson_id=coperson_id, org_identity_id=org_identity_id)

def coorg_identity_links_delete(self):
return coorg_identity_links_delete(self)
Expand Down
64 changes: 54 additions & 10 deletions comanage_api/_coorgidentitylinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

Methods
-------
coorg_identity_links_add() -> dict
### NOT IMPLEMENTED ###
coorg_identity_links_add(coperson_id: int, org_identity_id: int) -> dict
Add a new CO Org Identity Link.
A person must have an Org Identity and a CO Person record before they can be linked.
Note that invitations are a separate operation.
Expand All @@ -27,20 +26,65 @@
import json


def coorg_identity_links_add(self) -> dict:
def coorg_identity_links_add(self, coperson_id: int, org_identity_id: int) -> dict:
"""
### NOT IMPLEMENTED ###
Add a new CO Org Identity Link.
A person must have an Org Identity and a CO Person record before they can be linked.
Note that invitations are a separate operation.

:param self:
:return
501 Server Error: Not Implemented for url: mock://not_implemented_501.local:
coapi: COmanage API object
coperson_id: COmanage ID of CoPerson to link
orgidentity_id: COmanage ID of OrgIdentity to link
:request
{
"RequestType":"CoOrgIdentityLinks",
"Version":"1.0",
"CoOrgIdentityLinks":
[
{
"Version":"1.0",
"CoPersonId":"<CoPersonId>",
"OrgIdentityId":"<OrgIdentityId>"
}
]
}:

Response Format
HTTP Status Response Body Description
201 Added NewObjectResponse CoOrgIdentityLink created
400 Bad Request CoOrgIdentityLink Request not
provided in POST body
400 Invalid Fields ErrorResponse An error in one or more
provided fields
401 Unauthorized Authentication required
403 COPerson Does Not Exist The specified CO Person does not exist
403 OrgIdentity Already Linked The specified Org Identity is already
a member of this CO
403 OrgIdentity Does Not Exist The specified Org Identity does
not exist
500 Other Error Unknown error
"""
url = self._MOCK_501_URL
resp = self._mock_session.get(
url=url
post_body = {
"RequestType":"CoOrgIdentityLinks",
"Version":"1.0",
"CoOrgIdentityLinks":
[
{
"Version":"1.0",
"CoPersonId":"<CoPersonId>",
"OrgIdentityId":"<OrgIdentityId>"
}
]
}

post_body['CoOrgIdentityLinks'][0]['CoPersonId'] = coperson_id
post_body['CoOrgIdentityLinks'][0]['OrgIdentityId'] = org_identity_id

post_body = json.dumps(post_body)
url = self._CO_API_URL + '/co_org_identity_links.json'
resp = self._s.post(
url=url,
data=post_body
)
if resp.status_code == 201:
return json.loads(resp.text)
Expand Down
8 changes: 6 additions & 2 deletions examples/coorg_identity_links_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@
# must be set ahead of time and be valid within the CO
IDENTITY_TYPE = 'orgidentityid'
IDENTITY_ID = 190
CO_PERSON_ID = 163

# 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

# coorg_identity_links_add() -> dict
# coorg_identity_links_add(coperson_id: int, org_identity_id: int) -> dict
print('### coorg_identity_links_add')
try:
new_coorg_identity_link = api.coorg_identity_links_add()
new_coorg_identity_link = api.coorg_identity_links_add(
coperson_id=CO_PERSON_ID,
org_identity_id=IDENTITY_ID
)
print(json.dumps(new_coorg_identity_link, indent=4))
except HTTPError as err:
print('[ERROR] Exception caught')
Expand Down