From 169ac00d29c7566b595d52ed714856ff46cef90e Mon Sep 17 00:00:00 2001
From: Fabian Seidl <fabian.seidl@h-da.de>
Date: Thu, 24 Oct 2024 15:44:27 +0200
Subject: [PATCH] add client api for add, get, delete

---
 controller/api/subManagement.go | 46 +++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/controller/api/subManagement.go b/controller/api/subManagement.go
index f439d2413..afba1a831 100644
--- a/controller/api/subManagement.go
+++ b/controller/api/subManagement.go
@@ -35,3 +35,49 @@ func GetAll(ctx context.Context, addr string) (*subpb.GetAllResponse, error) {
 
 	return subClient.GetAll(ctx, req)
 }
+
+// Get fetches detailed info for one specific available subscription.
+func Get(ctx context.Context, addr string, subID string) (*subpb.GetResponse, error) {
+	subClient, err := nbi.SubManagementClient(addr, dialOptions...)
+	if err != nil {
+		return nil, err
+	}
+
+	req := &subpb.GetRequest{
+		Timestamp: time.Now().UnixNano(),
+		Subid:     subID,
+	}
+
+	return subClient.Get(ctx, req)
+}
+
+// Delete stops and removes one specific running subscription is a no-op if object connected to ID does not exist.
+func Delete(ctx context.Context, addr string, subID string) (*subpb.DeleteResponse, error) {
+	subClient, err := nbi.SubManagementClient(addr, dialOptions...)
+	if err != nil {
+		return nil, err
+	}
+
+	req := &subpb.DeleteRequest{
+		Timestamp: time.Now().UnixNano(),
+		Subid:     subID,
+	}
+
+	return subClient.Delete(ctx, req)
+}
+
+// Add creates a new subscription for the network element matching the provided ID using the provided subscribe options.
+func Add(ctx context.Context, addr string, mneID string, subscribeOptions *subpb.Subscription) (*subpb.AddResponse, error) {
+	subClient, err := nbi.SubManagementClient(addr, dialOptions...)
+	if err != nil {
+		return nil, err
+	}
+
+	req := &subpb.AddRequest{
+		Timestamp:    time.Now().UnixNano(),
+		Mneid:        mneID,
+		Subscription: subscribeOptions,
+	}
+
+	return subClient.Add(ctx, req)
+}
-- 
GitLab