Files
wehub-resource-sync bf9395e022
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / results (push) Has been cancelled
CI / deadcode (push) Has been cancelled
CI / e2e-live (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:22:54 +08:00

65 lines
1.9 KiB
Go

// Copyright (c) 2026 Lark Technologies Pte. Ltd.
// SPDX-License-Identifier: MIT
package okr
import (
"context"
"fmt"
"io"
"strconv"
"github.com/larksuite/cli/errs"
"github.com/larksuite/cli/shortcuts/common"
)
// OKRDeleteProgressRecord deletes a progress by ID.
var OKRDeleteProgressRecord = common.Shortcut{
Service: "okr",
Command: "+progress-delete",
Description: "Delete an OKR progress by ID",
Risk: "high-risk-write",
Scopes: []string{"okr:okr.progress:delete"},
AuthTypes: []string{"user", "bot"},
HasFormat: true,
Flags: []common.Flag{
{Name: "progress-id", Desc: "progress ID (int64)", Required: true},
},
Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
progressID := runtime.Str("progress-id")
if progressID == "" {
return errs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-id is required").WithParam("--progress-id")
}
if id, err := strconv.ParseInt(progressID, 10, 64); err != nil || id <= 0 {
return errs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-id must be a positive int64").WithParam("--progress-id")
}
return nil
},
DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
progressID := runtime.Str("progress-id")
return common.NewDryRunAPI().
DELETE("/open-apis/okr/v1/progress_records/:progress_id").
Set("progress_id", progressID).
Desc("Delete OKR progress")
},
Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
progressID := runtime.Str("progress-id")
path := fmt.Sprintf("/open-apis/okr/v1/progress_records/%s", progressID)
_, err := runtime.CallAPITyped("DELETE", path, nil, nil)
if err != nil {
return err
}
result := map[string]interface{}{
"deleted": true,
"progress_id": progressID,
}
runtime.OutFormat(result, nil, func(w io.Writer) {
fmt.Fprintf(w, "Deleted progress record %s\n", progressID)
})
return nil
},
}