@@ -10,6 +10,7 @@ import (
10
10
"github.com/redis/go-redis/v9"
11
11
"go.einride.tech/aip/filtering"
12
12
"golang.org/x/crypto/bcrypt"
13
+ "google.golang.org/grpc/metadata"
13
14
14
15
"github.com/instill-ai/mgmt-backend/internal/resource"
15
16
"github.com/instill-ai/mgmt-backend/pkg/acl"
@@ -65,6 +66,8 @@ type Service interface {
65
66
CheckUserPassword (ctx context.Context , uid uuid.UUID , password string ) error
66
67
UpdateUserPassword (ctx context.Context , uid uuid.UUID , newPassword string ) error
67
68
69
+ ListUserPipelines (ctx context.Context , id string ) ([]* pipelinePB.Pipeline , error )
70
+ ListOrganizationPipelines (ctx context.Context , id string ) ([]* pipelinePB.Pipeline , error )
68
71
ListPipelineTriggerRecords (ctx context.Context , owner * mgmtPB.User , pageSize int64 , pageToken string , filter filtering.Filter ) ([]* mgmtPB.PipelineTriggerRecord , int64 , string , error )
69
72
ListPipelineTriggerTableRecords (ctx context.Context , owner * mgmtPB.User , pageSize int64 , pageToken string , filter filtering.Filter ) ([]* mgmtPB.PipelineTriggerTableRecord , int64 , string , error )
70
73
ListPipelineTriggerChartRecords (ctx context.Context , owner * mgmtPB.User , aggregationWindow int64 , filter filtering.Filter ) ([]* mgmtPB.PipelineTriggerChartRecord , error )
@@ -802,3 +805,58 @@ func (s *service) DeleteOrganizationMembership(ctx context.Context, ctxUserUID u
802
805
}
803
806
return nil
804
807
}
808
+ func (s * service ) ListUserPipelines (ctx context.Context , id string ) ([]* pipelinePB.Pipeline , error ) {
809
+
810
+ pageToken := ""
811
+ pageSize := int32 (100 )
812
+
813
+ pipelines := []* pipelinePB.Pipeline {}
814
+ for {
815
+ resp , err := s .pipelinePublicServiceClient .ListUserPipelines (
816
+ metadata .AppendToOutgoingContext (ctx , "Jwt-Sub" , resource .GetRequestSingleHeader (ctx , constant .HeaderUserUIDKey )),
817
+ & pipelinePB.ListUserPipelinesRequest {
818
+ PageSize : & pageSize ,
819
+ PageToken : & pageToken ,
820
+ Parent : fmt .Sprintf ("users/%s" , id ),
821
+ },
822
+ )
823
+ if err != nil {
824
+ return nil , err
825
+ }
826
+ pipelines = append (pipelines , resp .Pipelines ... )
827
+ pageToken = resp .NextPageToken
828
+ if pageToken == "" {
829
+ break
830
+ }
831
+ }
832
+
833
+ return pipelines , nil
834
+ }
835
+
836
+ func (s * service ) ListOrganizationPipelines (ctx context.Context , id string ) ([]* pipelinePB.Pipeline , error ) {
837
+
838
+ pageToken := ""
839
+ pageSize := int32 (100 )
840
+
841
+ pipelines := []* pipelinePB.Pipeline {}
842
+ for {
843
+ resp , err := s .pipelinePublicServiceClient .ListOrganizationPipelines (
844
+ metadata .AppendToOutgoingContext (ctx , "Jwt-Sub" , resource .GetRequestSingleHeader (ctx , constant .HeaderUserUIDKey )),
845
+ & pipelinePB.ListOrganizationPipelinesRequest {
846
+ PageSize : & pageSize ,
847
+ PageToken : & pageToken ,
848
+ Parent : fmt .Sprintf ("organizations/%s" , id ),
849
+ },
850
+ )
851
+ if err != nil {
852
+ return nil , err
853
+ }
854
+ pipelines = append (pipelines , resp .Pipelines ... )
855
+ pageToken = resp .NextPageToken
856
+ if pageToken == "" {
857
+ break
858
+ }
859
+ }
860
+
861
+ return pipelines , nil
862
+ }
0 commit comments