Create/Delete objects

Hello I want to open a new thread just to clarify for me and probably for more people how to deal with create/delete object in genieacs.
I know that because of the nature of provision we can’t relay on the instance number, so to create a new one I use this on a particular CPE model and work just fine.

let d = declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.[]", null, {path: 3});
for (let instance of d){
	let vlan = declare(instance.path + ".X_TP_WANPonLinkConfig.VLANIDMark", {value: 1}).value[0];
	if (vlan == '-1'){
		let id = instance.path.slice(instance.path.lastIndexOf('.') + 1);
		declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice." + id + ".WANIPConnection.*", null, {path: 1});
		declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice." + id + ".WANIPConnection.1.Enable", {value: now}, {value: "true"});

But how to proceed when I want to delete that instance? I know that if I do this:

declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.[]", null, {path: 2});

the last instance on that branch is going to be remove, but there is nothing that really make that the removed one is the one that I want.
(Of course if nobody has been messing with the cpe it’s going to be the last provisioned but…)
I hope somebody can enlighten me about this situation.

And if there is a fastest trick to select by a parameter value something like:

let e = declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*.X_TP_WANPonLinkConfig.[VLANIDMark:52]", {value:})

or if it’s always needed to iterate on the whole branch?

Thank you.
Regards. Jorge.

The way to accomplish this is via what ever combination of param values make that instance unique.

Example if you wanted to delete the wan ip connection you’ve named “CustInternet” you would do this:

declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.WANConnectionDevice.*.WANIPConnection.[Name:CustInternet]", {path: 0});
1 Like

As good as always man.
Thank you very much.