Skip to content

External API

Okke Harsta edited this page Dec 28, 2021 · 21 revisions

Create Collaboration

The POST endpoint /api/collaborations/v1 can be used to create a new Collaboration. Use the API Key for the organisation to authenticate:

Authorization: Bearer ${API_KEY}
{
    "name": "new_collaboration",
    "description": "a description of the new CO",
    "administrators": ["[email protected]", "[email protected]"],
    "message": "Please join...",
    "short_name": "new_short_name",
    "expiration_date" : 1644015600,
    "logo": "/9j/4AAQSkZJRgABA...",
    "website_url": "https://web.nl",
    "disable_join_requests": true,
    "disclose_email_information": true,
    "disclose_member_information": true,

}

The optional logo is the base64 encoded binary image. The expiration_date is the UNIX epoch divided by 1000. The admin of the Collaboration is one of the admins of the Organisation. The response:

{
    "collaboration_memberships_count": 0,
    "created_at": 1640681285.0,
    "created_by": "urn:harry",
    "description": "Description",
    "disable_join_requests": true,
    "disclose_email_information": true,
    "disclose_member_information": true,
    "expiry_date": 1644015600.0,
    "global_urn": "uuc:new_short_name",
    "id": 5558,
    "identifier": "1c810012-b89b-4541-9336-19fab8951f3a",
    "invitations_count": 1,
    "last_activity_date": 1640681285.0,
    "logo": "http://localhost:8080/api/images/collaborations/df49667f-769f-432d-95b6-ea310f0eec1d",
    "name": "new_collaboration",
    "organisation_id": 4072,
    "short_name": "new_short_name",
    "status": "active",
    "updated_by": "urn:harry",
    "uuid4": "df49667f-769f-432d-95b6-ea310f0eec1d",
    "website_url": "https://web.nl"
}

Connect Service to Collaboration

The POST endpoint api/collaborations_services/v1/connect_collaboration_service can be used to connect an existing Service to an existing Collaboration. Use the API Key for the organisation to authenticate:

curl -i -H "Content-Type: application/json" -H "Authorization: Bearer ${API_KEY}" -X PUT -d '{"collaboration_id":2076, "service_entity_id":"https://cloud"}' "http://localhost:8080/api/collaborations_services/v1/connect_collaboration_service"
HTTP/1.0 201 CREATED

{
"collaboration_id":2076,
"collaboration_name":"AI computing",
"collaboration_urn":"ai_computing",
"organisation_name":"UUC",
"service_entity_id":
"https://cloud",
"service_id":4825,
"service_name":"Cloud",
"status":"connected"
}

Create Service Restricted Collaboration

The POST endpoint /api/collaborations/v1/restricted can be used to create a new Collaboration which Services are restricted. Authorise with an out-of-band received API user / password:

Authorization: Basic base64-encoded(user:password)
{
    "name": "new_collaboration",
    "description": "a description of the new CO",
    "administrator": "unix username of an user",
    "short_name": "new_short_name",
    "accepted_user_policy": "https://example.edu/aup.txt",
    "connected_services": ["https://cloud", "https://storage", "https://not_whitelisted"]
}

The schac_home_organisation of the administrator determines the organisation of the Collaboration; if no schac_home_organisation is found, SBS falls back to the default Organization for restricted COs as defined in config.yml.

The response:

{
	"created_at": 1580738647.0,
	"created_by": "sysread",
	"global_urn": "uuc:short_org_name",
	"identifier": "450e2ddb-05d2-407b-b8a1-27aae60d60a2",
	"name": "new_collaboration",
	"organisation_id": 10104,
	"services": [{
		"description": "SARA Cloud Service",
		"entity_id": "https://cloud",
		"name": "Cloud"
	}, {
		"description": "SURF Storage Service",
		"entity_id": "https://storage",
		"name": "Storage"
	}],
	"services_restricted": true,
	"short_name": "short_org_name",
	"status": "active",
	"updated_by": "sysread"
}

Only whitelisted services are actually linked to the new collaboration.

Example

─▶curl -i -u sysread:secret  -H "Content-Type: application/json" -X POST -d \
> '{"name": "new_collaboration", "administrator": "harry", "short_name": "short_org_name", "connected_services": ["https://network","https://wiki","https://storage","https://cloud"]}' \
>  "http://localhost:8080/api/collaborations/v1/restricted" 
HTTP/1.0 201 CREATED
Content-Type: application/json
Content-Length: 1155
x-session-alive: true
server: 
Date: Mon, 03 Feb 2020 15:43:23 GMT
{
	"accepted_user_policy": null,
	"access_type": null,
	"created_at": 1580744603.0,
	"created_by": "sysread",
	"description": null,
	"disable_join_requests": false,
	"enrollment": null,
	"global_urn": "uuc:short_org_name",
	"id": 17595,
	"identifier": "db9bba86-46d5-4732-b4b9-cacd2c6c71ba",
	"name": "new_collaboration",
	"organisation_id": 11701,
	"services": [{
		"accepted_user_policy": null,
		"address": null,
		"automatic_connection_allowed": true,
		"contact_email": null,
		"created_at": 1580742449.0,
		"created_by": "urn:admin",
		"description": "SARA Cloud Service",
		"entity_id": "https://cloud",
		"id": 40725,
		"identity_type": null,
		"name": "Cloud",
		"public_visible": true,
		"status": null,
		"updated_by": "urn:admin",
		"uri": null,
		"white_listed": false
	}, {
		"accepted_user_policy": null,
		"address": null,
		"automatic_connection_allowed": true,
		"contact_email": "[email protected]",
		"created_at": 1580742449.0,
		"created_by": "urn:admin",
		"description": "SURF Storage Service",
		"entity_id": "https://storage",
		"id": 40726,
		"identity_type": null,
		"name": "Storage",
		"public_visible": true,
		"status": null,
		"updated_by": "urn:admin",
		"uri": null,
		"white_listed": true
	}],
	"services_restricted": true,
	"short_name": "short_org_name",
	"status": "active",
	"updated_by": "sysread"
}

Invite Collaboration members

The PUT endpoint /api/invitations/v1/collaboration_invites can be used to invite members to an existing Collaboration. Use the API Key for the organisation to authenticate:

curl -i -H "Content-Type: application/json" -H "Authorization: Bearer kSOZTmFQuv_rLP5hAOmXwuKO0XGrdq6Fex6qGQ7Igiw" -X PUT -d '{"collaboration_id":14878, "invites":["[email protected]", "[email protected]", "invalid_email"]}' "http://localhost:8080/api/invitations/v1/collaboration_invites"
HTTP/1.0 201 CREATED
["[email protected]","[email protected]"]

The result is a list of emails where an invitation is send to. Optionally a message can be included in the PUT body that will be part of the invitation email. The intended role of the invitees is member.

Clone this wiki locally