Alert.png The wiki is deprecated and due to be decommissioned by the end of September 2022.
The content is being migrated to other supports, new updates will be ignored and lost.
If needed you can get in touch with EGI SDIS team using operations @ egi.eu.

Difference between revisions of "GOCDB/PI/Technical Documentation"

From EGIWiki
< GOCDB‎ | PI
Jump to navigation Jump to search
(Deprecate and redirect page)
Tag: Replaced
 
(30 intermediate revisions by 5 users not shown)
Line 3: Line 3:
{{TOC_top}}
{{TOC_top}}
[[Category:GOCDB]]
[[Category:GOCDB]]
== GOCDB Programmatic Interface ==
{{DeprecatedAndMovedTo|new_location=https://gocdb.github.io/api/}}
 
=== Important information about using the GOCDBPI ===
 
==== Releases, changes and announcements ====
All client tool using GOCDB should subscribe to the GOCDB discussion mailing list: [mailto:gocdb-discuss@mailman.egi.eu gocdb-discuss_at_mailman.egi.eu]. Releases, new features, changes in methods and general announcements related to this interface are made on this list.
 
If your application is using the GOCDB Programmatic interface please [https://mailman.egi.eu/mailman/listinfo/gocdb-discuss subscribe to gocdb-discuss] or send your subscription request by mail to [mailto:gocdb-admins@mailman.egi.eu gocdb-admins_at_mailman.egi.eu].
 
=== Interface description ===
 
==== <div id="PI">Interface type</div> ====
 
GOCDB Programmatic Interface is a [http://en.wikipedia.org/wiki/Representational_State_Transfer REST] (Representational State Transfer) based interface over https. The use of https guarantees URLs are properly secured when transiting. Some of the methods are nonetheless public and don't require client side authentication (see [[#Data protection and access]]).
 
==== Entry point ====
 
Enter GOCDB here https://goc.egi.eu/ or directly at https://goc.egi.eu/portal/ to browse and edit the global EGI information.
Entry point for every single method is given on method definition pages listed below.
 
==== Outputs ====
 
Output format is '''XML'''. Calling any implemented method will return you a valid DOM document that can be parsed by any tool on client side.
<!--- Removed from V5
==== Schemas ====
The associated '''XML schema''' for each method is available by calling the method with "&output=xmlschema", e.g. https://goc.egi.eu/gocdbpi/private/?method=get_site&output=xmlschema
-->
 
=== Data protection and access ===
 
==== Protection levels ====
 
There are currently 3 protection levels for all methods of the interface
 
* '''Level 1''': public methods (no critical information, no mail, no personal details)
* '''Level 2''': protected methods (contain mails or personal details)
* '''Level 3''': private methods (contains security or critical information)
 
Methods at level 1 are available without restrictions. Level 2 requires client to present a valid recognized X509 certificate (reference CA list is the officially agreed EGI/LCG EUGridPMA list). Level 3 requires client to present a known, registered certificate (certificate DN needs to be stored on GOCDB side for authentication)
 
==== How to gain access? ====
 
If you need to access protected methods, a valid certificate will be enough. If you need to access private methods, please send a mail to [mailto:gocdb-admins@mailman.egi.eu gocdb-admins_at_mailman.egi.eu], indicating:
 
* Your name and affiliation
* The name and purpose of the tool that need to access the data
* certificate DN of the machine(s) that will retrieve the information
* An e-mail contact for your application, that will be subscribed to the GOCDB-discussion and announcement mailing list if it is not already there.
 
== Data Visiblity ==
Sites and service endpoints can be shown or hidden from EGI and this affects what data is shown through the PI. By default the PI methods will return only objects that are marked as visible to EGI. For example get_site will, by default, return only sites that are visible to EGI. Similarly, get_downtime will only show downtimes that are linked to EGI service endpoints.
 
The "scope=Local" parameter can be used to access non-EGI data through the PI. For example:
https://goc.egi.eu/gocdbpi/private/?method=get_site&scope=Local
 
Our user facing documentation for this feature is available at [[GOCDB/Input System User Documentation#Data_Visibility]].
 
=== Available methods  ===
 
{| border="1"
|-
! Method name
! type
! description
! Protection level
|-
| [[GOCDB/PI/get site method|get_site]]
| read - generic
| Returns site information including contacts, grouped by site
| 2
|-
| [[GOCDB/PI/get site list method|get_site_list]]
| read - generic
| Returns a list of sites with minimal associated information
| 1
|-
| [[GOCDB/PI/get site contacts method|get_site_contacts]]
| read - generic
| Returns a list of persons (and associated info) having a role at site level, grouped per site
| 2
|-
| [[GOCDB/PI/get site security info method|get_site_security_info]]
| read - generic
| Returns security contact information for sites
| 3
|-
| [[GOCDB/PI/get roc list method|get_roc_list]]
| read - generic
| Returns a list of NGIs with minimal associated information
| 1
|-
| [[GOCDB/PI/get subgrid list method|get_subgrid_list]]
| read - generic
| Returns a list of Subgrids (i.e. registered sub-parts of an NGI) with minimal associated information
| 1
|-
| [[GOCDB/PI/get roc contacts method|get_roc_contacts]]
| read - generic
| Returns NGI contact details, including NGI contact mail address and list of NGI staff
| 2
|-
| <strike>[[GOCDB/PI/get egee contacts method|get_egee_contacts]]</strike>
| read - generic
| <strike>Returns a list of contacts for staff that have a role a EGI level</strike>
| 2
|-
| [[GOCDB/PI/get downtime method|get_downtime]]
| read - generic
| Returns a list of EGI downtimes for sites and nodes
| 1
|-
| [[GOCDB/PI/get service endpoint method|get_service_endpoint]]
| read - generic
| Returns a list of service endpoints (single node x single service) and associated information
| 1
|-
| [[GOCDB/PI/get service types method|get_service_types]]
| read - generic
| Returns a list of valid service types and associated description
| 1
|-
| [[GOCDB/PI/get user method|get_user]]
| read - generic
| Returns a user or a list of users with associated details and roles
| 2
|-
| [[GOCDB/PI/get downtime to broadcast method|get_downtime_to_broadcast]]
| read - dedicated
| Returns the list of downtimes recently declared with notification settings for CIC portal downtime notification service
| 2
|-
| [[GOCDB/PI/get cert status changes|get_cert_status_changes]]
| read - generic
| Returns a list of changes to certification statuses
| 2
|-
| [[GOCDB/PI/get cert status date|get_cert_status_date]]
| read - generic
| Returns a list of current certification statuses for Production sites and the date they entered that status
| 2
|-
| [[GOCDB/PI/get service group|get_service_group]]
| read - generic
| Returns a list of service groups and the service endpoints under those groups.
| 2
|-
| [[GOCDB/PI/get service group role|get_service_group_role]]
| read - generic
| Returns a list of service groups and the roles held by users over these groups.
| 2
|-
| [[GOCDB/PI/get ngi|get_ngi]]
| read - generic
| Returns a list of NGIs with contact information
| 2
|}
 
'''Note about parameters:'''
 
*Unless otherwise stated, all parameters are optional. If no parameter is given, all methods will return results with the wider scope possible.
*It is possible to combine parameters, for example: ''?method=get_site&amp;country=Italy&amp;certification_status=Certified&amp;production_status=Production''
 
=== Client code examples ===
 
==== Simple data retrieval using wget ====
 
If getting the data locally is what you're after, a simple cron job retrieving data via wget might do the trick.
 
* Public methods: You do not need any client certificate, so a simple wget instruction should work:
 
$ wget --no-check-certificate -O result.xml <nowiki>'https://goc.egi.eu/gocdbpi/public/?method=get_site_list&sitename=RAL-LCG2'</nowiki>
 
''--no-check-certificate'' option might be needed to avoid server verification. Note also that URL should be encapsulated into single quotes.
 
* Protected and private methods: Here you will need authentication, which can be done through wget as shown in next example:
 
$ wget --certificate=cert.pem --private-key=cert.key.pem --private-key-type=PEM --ca-directory=/etc/grid-security/certificates/ -O result.xml <nowiki>'https://goc.egi.eu/gocdbpi/private/?method=get_site&sitename=RAL-LCG2'</nowiki>
 
Note that if you don't specify the --ca-directory option, SSL handshake may fail as server cert cannot be checked.
 
'''Note:''' examples are shown using wget-10.2. Some discrepencies are observed between version so check wget help for correct options. Bugs and weird behaviour have also been observed for wget with a version older than 10.
 
==== Perl example ====
 
Provided by Emir Imamagic, SRCE. This code is used by NCG
 
The 3 following examples are GOCDB modules in perl which use LWP::UserAgent for accessing PI and XML::DOM for parsing the data. Data is used to fill internal NCG structure.
 
* [http://svnweb.cern.ch/world/wsvn/sam/trunk/grid-monitoring-config-gen/src/modules/NCG/SiteSet/GOCDB.pm Get site list (public method)]
* [http://svnweb.cern.ch/world/wsvn/sam/trunk/grid-monitoring-config-gen/src/modules/NCG/SiteInfo/GOCDB.pm Get service endpoints (public)]
* [http://svnweb.cern.ch/world/wsvn/sam/trunk/grid-monitoring-config-gen/src/modules/NCG/SiteContacts/GOCDB.pm Get site contacts (protected)]
 
Nagios plugin nagios-gocdb-downtime is used for retrieving downtimes and pushing them to Nagios via GridMon::Nagios module:
 
* [http://svnweb.cern.ch/world/wsvn/sam/trunk/nagios-gocdb-downtime/src/nagios-gocdb-downtime Nagios gocdb downtime]
 
<!--'''note:''' Full code is available from [https://twiki.cern.ch/twiki/bin/view/EGEE/EGEESA1SourceRepository EGEE SA1 Source code repository]-->
'''note''' Full code is available from [http://svnweb.cern.ch/world/wsvn/sam cern svn]
 
==== PHP example ====
 
Provided by Guillaume Cessieux, CC-IN2P3. This code is used by ENOC
 
The following example shows a simple PHP class with methods used to retrieve and parse XML data from GOCDB-PI using PHP curl and simplexml
* [[GOCDB/PI/Technical_Documentation/client_php]]
 
 
==== Python example ====
 
Provided by Giuseppe Misurelli, CNAF-INFN
 
The following example is a Python client that queries the GOCDB programmatic interface, retrieves info about downtimes for a top entity region using curl, parses xml output with the xml.dom.minidom module and stores data into a MySQl db.
 
* [https://documents.egi.eu/secure/RetrieveFile?docid=471&version=2&filename=Get_downtimes_python_example.tar.gz Get_downtimes_python_example.tar.gz]
 
=== New requests and improvements ===
 
Requests on GOCDB-PI can take the form of:
 
* Change request to an existing method
* Request for new generic methods
* Request for tool specific methods
 
Such requests are logged in [https://rt.egi.eu/rt/Search/Results.html?Format=%27%20%20%20%3Cb%3E%3Ca%20href%3D%22__WebPath__%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__id__%3C%2Fa%3E%3C%2Fb%3E%2FTITLE%3A%23%27%2C%0A%27%3Cb%3E%3Ca%20href%3D%22__WebPath__%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__Subject__%3C%2Fa%3E%3C%2Fb%3E%2FTITLE%3ASubject%27%2C%0A%27__Status__%27%2C%0A%27__QueueName__%27%2C%0A%27__OwnerName__%27%2C%0A%27__Priority__%27%2C%0A%27__NEWLINE__%27%2C%0A%27%27%2C%0A%27%3Csmall%3E__Requestors__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__CreatedRelative__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__ToldRelative__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__LastUpdatedRelative__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__TimeLeft__%3C%2Fsmall%3E%27&Order=ASC|ASC|ASC|ASC&OrderBy=id|||&Query=Queue%20%3D%20%27requirements%27%20AND%20%28%20%20Status%20%3D%20%27new%27%20OR%20Status%20%3D%20%27open%27%20OR%20Status%20%3D%20%27accepted%27%20OR%20Status%20%3D%20%27developed%27%20OR%20Status%20%3D%20%27stalled%27%20OR%20Status%20%3D%20%27feedback%27%20%29%20AND%20%27CF.{Category%20%28level%202%29}%27%20LIKE%20%27GOCDB%20%28Operational%20Tools%29%27%20AND%20Queue%20%3D%20%27requirements%27%20AND%20%27CF.{Category%20%28level%201%29}%27%20LIKE%20%27Operational%20Tools%27&RowsPerPage=50&SavedChartSearchId=new&SavedSearchId=RT%3A%3AUser-3851-SavedSearch-1174 The GOCDB RT Requirements Queue Tickets]: View and submit RT Requirements tickets specifically for GOCDB

Latest revision as of 17:45, 15 November 2022