· Feb 29

Programmatic Access to External-Service Registry

One can modify Interoperability External-Service Registry in Management Portal (Interoperability > Configure > External-Service Registry).

Can the registry be accessed and modified programmatically?

I don't find much documentation about the subject. Mainly

Product version: IRIS 2022.1
$ZV: IRIS for UNIX (Ubuntu Server LTS for x86-64 Containers) 2022.1.2 (Build 574_0_22161U) Tue Jan 24 2023 11:05:57 EST
Discussion (3)2
Log in or sign up to continue

Based on the hint from @Stephen Canzano I figured out the following examples that seems to do the job:

/// How to programmatically access External-Service Registry:
Class OSEX.Ex.ExternalServiceRegistry Extends %RegisteredObject

/// list services
ClassMethod Ex1()
	#dim services // md
	do ##class(Ens.ServiceRegistry.External.API).ListServices(.services)
	#dim id as %Integer = $order(services(""))
	while (id '= "" ) {
		#dim val as %DynamicObject = {}.%FromJSON($get(services(id)))
		write "--------------------",!
		write "#"_id_" Name: "_val.Name,!
		write "#"_id_" Domain: "_val.Domain,!
		write "#"_id_" Version: "_val.Version,!
		write "#"_id_" exists: "_##class(Ens.ServiceRegistry.External.API).ExistsService(val.Name,val.Domain,val.Version),!
		write "#"_id_" json: "_val.%ToJSON(),!
		set id = $order(services(id))
	//zw services

/// add/modify service
ClassMethod Ex2()
	#dim service = ##class(%ZEN.proxyObject).%New()
	set service.Name = "Foo Service"
	set service.Domain = "OSEX"
	set service.Version = "1"
	set service.Endpoint = "http://localhost:8080/foo"
	set service.Protocol = "REST"
	set service.ResponseStyle = "Sync"
	set service.Stage = "Live"
	zw service
	#dim status as %Status = ##class(Ens.ServiceRegistry.External.API).SaveService(service)
	zw status
	set service.Name = "Bar Service"
	set service.Endpoint = "http://localhost:8080/bar"

	zw ##class(Ens.ServiceRegistry.External.API).SaveService(service)

/// delete service
ClassMethod Ex3()
	#dim pid as %String = "Foo Service||OSEX||1"
	#dim status as %String = ##class(Ens.ServiceRegistry.External.API).DeleteService(pid)
	zw status