@@ -30,6 +30,8 @@ import (
3030
3131var nonce = int64 (0 )
3232
33+ var allocationIDRequired = errors .Errorf ("Allocation ID is required" )
34+
3335type Autorizer interface {
3436 Auth (msg string ) (string , error )
3537}
@@ -327,6 +329,49 @@ func (s *StorageSDK) FinalizeAllocation(allocationID string) (string, error) {
327329 return hash , err
328330}
329331
332+ // RepairAllocation repair allocation
333+ // - allocationID: allocation ID
334+ func (s * StorageSDK ) RepairAllocation (allocationID string ) error {
335+ // Validate allocation ID
336+ if allocationID == "" {
337+ return allocationIDRequired
338+ }
339+
340+ // Get allocation
341+ alloc , err := sdk .GetAllocation (allocationID )
342+ if err != nil {
343+ return err
344+ }
345+
346+ // returns an error if allocation is not found or caller is not the owner
347+ if alloc .Owner != client .Id () {
348+ return errors .Errorf ("Allocation access denied for repair: %s" , alloc .Owner )
349+ }
350+
351+ // Call repair with nil StatusCallback (no progress updates for mobile, ios implementation provides statusUpdates)
352+ return alloc .RepairAlloc (nil )
353+ }
354+
355+ // CancelRepair cancel repair for allocation
356+ // - allocationID: allocation ID
357+ func (s * StorageSDK ) CancelRepair (allocationID string ) error {
358+ if allocationID == "" {
359+ return allocationIDRequired
360+ }
361+
362+ alloc , err := sdk .GetAllocation (allocationID )
363+ if err != nil {
364+ return err
365+ }
366+
367+ //returns an error if allocation is not found or caller is not the owner
368+ if alloc .Owner != client .Id () {
369+ return errors .Errorf ("Allocation access denied for cancelling the repair: %s" , alloc .Owner )
370+ }
371+
372+ return alloc .CancelRepair ()
373+ }
374+
330375// CancelAllocation cancel allocation by ID
331376// - allocationID: allocation ID
332377func (s * StorageSDK ) CancelAllocation (allocationID string ) (string , error ) {
0 commit comments