Skip to content
Snippets Groups Projects
subManagement.go 993 B
Newer Older
  • Learn to ignore specific revisions
  • package api
    
    import (
    	"context"
    	"time"
    
    	subpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/subscriptionmanagement"
    	nbi "code.fbi.h-da.de/danet/gosdn/controller/northbound/client"
    )
    
    // ResetAllSubscriptions stops all running subscriptions and restarts them the same way they ran before.
    func ResetAllSubscriptions(ctx context.Context, addr string) (*subpb.ResetAllSubscriptionsResponse, error) {
    	subClient, err := nbi.SubManagementClient(addr, dialOptions...)
    	if err != nil {
    		return nil, err
    	}
    
    	req := &subpb.ResetAllSubscriptionsRequest{
    		Timestamp: time.Now().UnixNano(),
    	}
    
    	return subClient.ResetAllSubscriptions(ctx, req)
    }
    
    // GetAll returns information about all running subscriptions.
    func GetAll(ctx context.Context, addr string) (*subpb.GetAllResponse, error) {
    	subClient, err := nbi.SubManagementClient(addr, dialOptions...)
    	if err != nil {
    		return nil, err
    	}
    
    	req := &subpb.GetAllRequest{
    		Timestamp: time.Now().UnixNano(),
    	}
    
    	return subClient.GetAll(ctx, req)
    }