Manage Catalogue Items
Obtain Token to Create Catalogue
To create/update/delete a catalogue
entry in the IUDX Catalogue Server, a provider should obtain a token using IUDX Authorization Servers Create Token APIs.
To obtain a token, a provider can either specify their clientId
and clientSecret
in the header or specify a token header. The clientId
and clientSecret
are generated for a provider on their Successful Registration.
A provider can obtain a token using the Create Token APIs with the following request body.
{
"itemId": "datakaveri.org/04a15c9960ffda227e9546f3f46e629e1fe4132b/catalogue.iudx.org.in/catalogue/crud",
"itemType": "resource",
"role": "provider"
}
The itemId
here specifies the catalogue instance in the IUDX Catalogue Server in which the provider intends to perform a create/update/delete operation and is represented in the following format:
<provider-domain>/<SHA1-of-provider-email>/<catalogue-url>/catalogue/crud
It is to be noted that a provider would be entitled to create/update/delete catalogue
entries only on their catalogue instances through an explicit policy specified by the IUDX Admin in the IUDX Authorization Server. A provider will not obtain any token to perform create/update/delete operations on the catalogue
entries for other catalogue instances in the IUDX Catalogue Server.
Upload Catalogue Entries to the Catalogue Server
On successfully obtaining a Create Catalogue Token, a provider can upload the catalogue
entries to the IUDX Catalogue Server.
Assuming the catalogue
entries for provider
and resource_server
are already uploaded by the IUDX Admin, a provider can know insert the entries for resource_group
followed by the entries for the resource
to the IUDX Catalogue Server.
The Python script below shows an example of inserting a catalogue
entry to the IUDX Catalogue Server using the Create Item API.
import json
import requests
catalogue_url = 'api.catalogue.iudx.org.in'
token = '<token_obtained_from_IUDX_Authorization_Servers>'
path = '<./path_to_the_catalogue_entry_file>'
api = 'https://' + catalogue_url + '/iudx/cat/v1/item'
headers = {'content-type': 'application/json', 'token': token}
with open(path, 'r') as catalogue_file:
catalogue_item = json.load(catalogue_file)
r = requests.post(api, json.dumps(catalogue_item), headers=headers)
print r.status_code
print r.json()