consume {
if (instanceOf(input, NRFSpecificationUDR)) {
nrf.NRFSpecificationUDR udr = udrCreate(nrf.NRFSpecificationUDR);
udr.registerCycleUDR = constructRegUdr();
udr.heartbeatCycleUDR = constructHbUDR();
udr.deregisterCycleUDR = constructDeRegUDR();
udr.heartBeatFieldName = "heartBeatTimer";
udr.nfInstanceIdFieldName = "nfInstanceId";
udr.nfTypeFieldName = "nfType";
udr.nfProfileChangesSupportIndFieldName = "nfProfileChangesSupportInd";
udrRoute(udr);
}
}
RequestCycle constructRegUdr() {
// construct register UDR
NFProfile nfUdr = udrCreate(NFProfile);
nfUdr.nfInstanceId = "94d7f196-9d03-11eb-a8b3-0242ac130003";
nfUdr.heartBeatTimer = 5;
nfUdr.fqdn = "domain.my";
nfUdr.nfType = "CHF";
nfUdr.nfStatus = "REGISTERED";
nfUdr.nfProfileChangesSupportInd = false;
list<string> ipv4List = listCreate(string);
listAdd(ipv4List, "10.60.10.111");
list<string> ipv6List = listCreate(string);
listAdd(ipv6List, "2001:db8:85a3::8a2e:370:7334");
nfUdr.ipv4Addresses = ipv4List;
nfUdr.ipv6Addresses = ipv6List;
string jsonString = jsonEncodeUdr(nfUdr);
bytearray ba;
strToBA(ba, jsonString);
http.RequestCycle regUDR = udrCreate(http.RequestCycle);
map<string,list<string>> headersMap = mapCreate(string, list<string>);
list<string> contentList = listCreate(string);
listAdd(contentList, "application/json");
mapSet(headersMap, "Content-Type", contentList);
regUDR.headers = headersMap;
regUDR.method = "PUT";
regUDR.requestTimeout = 10000;
regUDR.body = ba;
regUDR.openAPIUDR = nfUdr;
regUDR.path = "/nnrf-nfm/v1/nf-instances/94d7f196-9d03-11eb-a8b3-0242ac130003";
return regUDR;
}
RequestCycle constructHbUDR() {
// construct heartbeat UDR
PatchItem patchUDR = udrCreate(PatchItem);
patchUDR.op = "replace";
patchUDR.path = "/nfstatus1";
patchUDR.value = "REGISTERED";
string jsonString = "[" + jsonEncodeUdr(patchUDR) + "]";
bytearray ba;
strToBA(ba, jsonString);
http.RequestCycle hbUDR = udrCreate(http.RequestCycle);
map<string,list<string>> hbHeadersMap = mapCreate(string, list<string>);
list<string> hbContentList = listCreate(string);
listAdd(hbContentList, "application/json-patch+json");
mapSet(hbHeadersMap, "Content-Type", hbContentList);
hbUDR.headers = hbHeadersMap;
hbUDR.method = "PATCH";
hbUDR.requestTimeout = 10000;
hbUDR.body = ba;
hbUDR.openAPIUDR = patchUDR;
hbUDR.path = "/nnrf-nfm/v1/nf-instances/94d7f196-9d03-11eb-a8b3-0242ac130003";
return hbUDR;
}
RequestCycle constructDeRegUDR() {
// construct de-registration UDR
http.RequestCycle udr = udrCreate(http.RequestCycle);
udr.method = "DELETE";
udr.requestTimeout = 10000;
udr.path = "/nnrf-nfm/v1/nf-instances/94d7f196-9d03-11eb-a8b3-0242ac130003";
return udr;
} |