## A1 API The `github.com/onosproject/onos-ric-sdk-go/pkg/a1` package provides an interface for interacting with onos-topo for the establishment of the xApp registration, as an entity, and setup of onos-a1t related Aspects, for instance the xApp supported policy Type IDs. Currently A1T only supports the Policy Management service, all the implementation for Enrichment Information service is done however there are no schemas defined for EI Job Type IDs. ### Creating the A1 connection manager To create the manager of the A1 connection with onos-topo the information about the supported policy Type IDs needs to be specified, jointly with the parameters for the gRPC connection (e.g., certificate, key, grpc port). In the following code snipped an example is provided. ```go import ( "context" "github.com/onosproject/onos-api/go/onos/topo" "github.com/onosproject/onos-lib-go/pkg/logging" a1connection "github.com/onosproject/onos-ric-sdk-go/pkg/a1/connection" ) var log = logging.GetLogger() type Config struct { PolicyName string PolicyVersion string PolicyID string PolicyDescription string A1tPort int } // Creates a a1 connection manager with onos-topo so the xApp can be added as an entity, and have in its aspects the annotations of the supported a1PolicyTypes. // The registration of the xApp in onos-topo is done upon the Start of the a1 connection manager. func NewManager(caPath string, keyPath string, certPath string, grpcPort int, xAppName string, a1PolicyTypes []*topo.A1PolicyType) (*Manager, error) { a1ConnManager, err := a1connection.NewManager(caPath, keyPath, certPath, grpcPort, a1PolicyTypes) if err != nil { return nil, err } return &Manager{ a1ConnManager: a1ConnManager, }, nil } type Manager struct { a1ConnManager *a1connection.Manager } func (m *Manager) Start() { m.a1ConnManager.Start(context.Background()) } func (m *Manager) Close(ctx context.Context) { err := m.a1ConnManager.DeleteXAppElementOnTopo(ctx) if err != nil { log.Error(err) } } ``` When the manager is created and its Start method is invoked, the xApp will be registered in onos-topo as an Entity. with that information onos-a1t can discover the xApps supporting A1 interface and interact with them via their northbound implementation of A1 gRPC services for Policy Management and Enrichment Information (see next section). ### Northbound implementation of A1 interface To interact with onos-a1t an xApp needs to provide an implementation of gRPC services for Policy Management and Enrichment Information, as defined by the package `github.com/onosproject/onos-api/go/onos/a1t/a1`. The Policy Management service defines the following methods to be implemented by an xApp northbound server (see `https://github.com/onosproject/onos-api/blob/master/proto/onos/a1t/a1/policy.proto`). ```protobuf service PolicyService { rpc PolicySetup (PolicyRequestMessage) returns (PolicyResultMessage); rpc PolicyUpdate (PolicyRequestMessage) returns (PolicyResultMessage); rpc PolicyDelete (PolicyRequestMessage) returns (PolicyResultMessage); rpc PolicyQuery (PolicyRequestMessage) returns (PolicyResultMessage); rpc PolicyStatus (stream PolicyAckMessage) returns (stream PolicyStatusMessage); } ``` The Enrichment Information service defines the following methods to be implemented by an xApp northbound server (see `https://github.com/onosproject/onos-api/blob/master/proto/onos/a1t/a1/ei.proto`). ```protobuf service EIService { rpc EIQuery (stream EIResultMessage) returns (stream EIRequestMessage); rpc EIJobSetup (stream EIResultMessage) returns (stream EIRequestMessage); rpc EIJobUpdate (stream EIResultMessage) returns (stream EIRequestMessage); rpc EIJobDelete (stream EIResultMessage) returns (stream EIRequestMessage); rpc EIJobStatusQuery (stream EIResultMessage) returns (stream EIRequestMessage); rpc EIJobStatusNotify (EIStatusMessage) returns (EIAckMessage); rpc EIJobResultDelivery (EIResultMessage) returns (EIAckMessage); } ``` ### xApp reference implementation Examples of those implementation can be seen in onos-a1t integration tests, where a generic xApp implementation is provided (see `https://github.com/onosproject/onos-a1t/tree/master/test/utils/xapp/pkg`). In that example the xApp defines both the implementation of the a1 connection manager with onos-topo using the `onos-ric-sdk-go` a1 package, as well as the implementation of the methods that realize the Policy and EI gRPC services.