Versions Compared

Key

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

Jira
serverONAP JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-392

Investigate A&AI Interface, especially how to retrieve inventory, current list of xNF functions

Consider som PoC Code

Documentation:

AAI REST API Documentation - Honolulu

How to retrieve current list of xNF functions from A&AI:

Send Get request to this endpoint

Example curl command you can use to retrieve inventory from anywhere within the cluster in which AAI is deployed to.

Code Block
titleExample curl command
curl 'http://aai:8443/aai/v23/network/pnfs'

PoC code:

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";
    }

}