(ctx context.Context, id string)
| 906 | } |
| 907 | |
| 908 | func (i *imlServiceModule) Delete(ctx context.Context, id string) error { |
| 909 | err := i.transaction.Transaction(ctx, func(ctx context.Context) error { |
| 910 | count, err := i.apiService.CountByService(ctx, id) |
| 911 | if err != nil { |
| 912 | return err |
| 913 | } |
| 914 | if count > 0 { |
| 915 | return fmt.Errorf("service has apis, can not delete") |
| 916 | } |
| 917 | |
| 918 | err = i.serviceService.Delete(ctx, id) |
| 919 | if err != nil { |
| 920 | return err |
| 921 | } |
| 922 | |
| 923 | err = i.serviceModelMappingService.Delete(ctx, id) |
| 924 | if err != nil { |
| 925 | return err |
| 926 | } |
| 927 | client, err := i.clusterService.GatewayClient(ctx, cluster.DefaultClusterID) |
| 928 | if err != nil { |
| 929 | return err |
| 930 | } |
| 931 | err = client.Project().Offline(ctx, &gateway.ProjectRelease{ |
| 932 | Id: id, |
| 933 | }) |
| 934 | if err != nil { |
| 935 | if err.Error() != "nil" { |
| 936 | return err |
| 937 | } |
| 938 | } |
| 939 | err = client.Subscribe().Offline(ctx, &gateway.SubscribeRelease{ |
| 940 | Service: id, |
| 941 | Application: "apipark-global", |
| 942 | Expired: "0", |
| 943 | }) |
| 944 | if err != nil { |
| 945 | return err |
| 946 | } |
| 947 | |
| 948 | err = client.Hash().Offline(ctx, &gateway.HashRelease{ |
| 949 | HashKey: fmt.Sprintf("%s:%s", gateway.KeyServiceMapping, id), |
| 950 | }) |
| 951 | if err != nil { |
| 952 | return err |
| 953 | } |
| 954 | i.deleteMCPServer(ctx, id) |
| 955 | return nil |
| 956 | }) |
| 957 | return err |
| 958 | } |
| 959 | |
| 960 | func (i *imlServiceModule) getTagUuids(ctx context.Context, tags []string) ([]string, error) { |
| 961 | list, err := i.tagService.Search(ctx, "", map[string]interface{}{"name": tags}) |
nothing calls this directly
no test coverage detected