Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Write code to show that it is possible to retrieve the current list of xNF functions.

Code Block
languagejava
titlePoC code
collapsetrue
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class InventoryRetriever {

    public void getXnfsFromAai(){
        String nfData;
        try{
            HttpClient client = HttpClient.newHttpClient();
            String aaiNetworkEndPoint = getAaiServiceUrl();
            var request = HttpRequest.newBuilder(URI.create(aaiNetworkEndPoint))
                    .headers("Authorization", "Basic QUFJOkFBSQ==", "accept", "application/json",
                            "content-type", "application/json", "x-fromappid", "cps-ncmp",
                            "X-TransactionId", "get_aai_subscr")
                    .build();
            var response = client.send(request, HttpResponse.BodyHandlers.ofString());
            if (response.statusCode() == 200){
                nfData = response.body();
                System.out.println(nfData);
            }
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }

    private String getAaiServiceUrl(){
        String version = "v23";
        return "http://aai:8443/aai/"+ version + "/network/pnfs";
    }

}