MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / RevokeSubscription

Method RevokeSubscription

module/subscribe/iml.go:143–181  ·  view source on GitHub ↗
(ctx context.Context, pid string, uuid string)

Source from the content-addressed store, hash-verified

141}
142
143func (i *imlSubscribeModule) RevokeSubscription(ctx context.Context, pid string, uuid string) error {
144 _, err := i.serviceService.Get(ctx, pid)
145 if err != nil {
146 return fmt.Errorf("get service error: %w", err)
147 }
148 subscription, err := i.subscribeService.Get(ctx, uuid)
149 if err != nil {
150 return err
151 }
152 if subscription.ApplyStatus != subscribe.ApplyStatusSubscribe {
153 return fmt.Errorf("subscription can not be revoked")
154 }
155
156 clusters, err := i.clusterService.List(ctx)
157 if err != nil {
158 return err
159 }
160 applyStatus := subscribe.ApplyStatusUnsubscribe
161 return i.transaction.Transaction(ctx, func(ctx context.Context) error {
162 err = i.subscribeService.Save(ctx, uuid, &subscribe.UpdateSubscribe{
163 ApplyStatus: &applyStatus,
164 })
165 if err != nil {
166 return err
167 }
168 for _, c := range clusters {
169 err = i.offlineForCluster(ctx, c.Uuid, &gateway.SubscribeRelease{
170 Service: subscription.Service,
171 Application: subscription.Application,
172 })
173 if err != nil {
174 return err
175 }
176 }
177
178 return nil
179 })
180
181}
182
183func (i *imlSubscribeModule) DeleteSubscription(ctx context.Context, pid string, uuid string) error {
184 _, err := i.serviceService.Get(ctx, pid)

Callers

nothing calls this directly

Calls 4

offlineForClusterMethod · 0.95
GetMethod · 0.65
ListMethod · 0.65
SaveMethod · 0.65

Tested by

no test coverage detected