Question Jani Hurskainen · Feb 29, 2024

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 https://docs.intersystems.com/irisforhealth20221/csp/docbook/DocBook.UI…

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

Comments

Stephen Canzano · Feb 29, 2024

This information is found in the class

Ens.ServiceRegistry.External.Service

0
Jani Hurskainen  Mar 4, 2024 to Stephen Canzano

In my setup no such class exists. The correct class seems to be Ens.ServiceRegistry.External.API. API-class seems to be a mixed bag of public programming interface methods and private implementation ([Internal] methods).

0
Jani Hurskainen · Mar 4, 2024

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

/// How to programmatically access External-Service Registry:/// https://docs.intersystems.com/irisforhealth20221/csp/docbook/DocBook.UI.Page.cls?KEY=EESB_registry_admin#EESB_registry_admin_externalClass OSEX.Ex.ExternalServiceRegistry Extends%RegisteredObject
{

/// list servicesClassMethod Ex1()
{
	#dim services // mddo##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 serviceClassMethod 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 serviceClassMethod Ex3()
{
	#dim pid as%String = "Foo Service||OSEX||1"#dim status as%String = ##class(Ens.ServiceRegistry.External.API).DeleteService(pid)
	zw status
}

}
0