@@ -112,6 +112,73 @@ func dryRunRecordHistoryList(_ context.Context, runtime *common.RuntimeContext)
112112 Set ("base_token" , runtime .Str ("base-token" ))
113113}
114114
115+ func dryRunRecordShareBatch (_ context.Context , runtime * common.RuntimeContext ) * common.DryRunAPI {
116+ recordIDs := deduplicateRecordIDs (runtime )
117+ return common .NewDryRunAPI ().
118+ POST ("/open-apis/base/v3/bases/:base_token/tables/:table_id/records/share_links/batch" ).
119+ Body (map [string ]interface {}{"record_ids" : recordIDs }).
120+ Set ("base_token" , runtime .Str ("base-token" )).
121+ Set ("table_id" , baseTableID (runtime ))
122+ }
123+
124+ func dryRunRecordShare (_ context.Context , runtime * common.RuntimeContext ) * common.DryRunAPI {
125+ return common .NewDryRunAPI ().
126+ POST ("/open-apis/base/v3/bases/:base_token/tables/:table_id/records/:record_id/share_links" ).
127+ Set ("base_token" , runtime .Str ("base-token" )).
128+ Set ("table_id" , baseTableID (runtime )).
129+ Set ("record_id" , runtime .Str ("record-id" ))
130+ }
131+
132+ func validateRecordShareBatch (runtime * common.RuntimeContext ) error {
133+ recordIDs := deduplicateRecordIDs (runtime )
134+ if len (recordIDs ) == 0 {
135+ return common .FlagErrorf ("--record-ids is required and must not be empty" )
136+ }
137+ if len (recordIDs ) > maxShareBatchSize {
138+ return common .FlagErrorf ("--record-ids exceeds maximum limit of %d (got %d)" , maxShareBatchSize , len (recordIDs ))
139+ }
140+ return nil
141+ }
142+
143+ func deduplicateRecordIDs (runtime * common.RuntimeContext ) []string {
144+ raw := runtime .StrSlice ("record-ids" )
145+ seen := make (map [string ]bool , len (raw ))
146+ result := make ([]string , 0 , len (raw ))
147+ for _ , id := range raw {
148+ if id != "" && ! seen [id ] {
149+ seen [id ] = true
150+ result = append (result , id )
151+ }
152+ }
153+ return result
154+ }
155+
156+ func executeRecordShareBatch (runtime * common.RuntimeContext ) error {
157+ recordIDs := deduplicateRecordIDs (runtime )
158+ body := map [string ]interface {}{
159+ "record_ids" : recordIDs ,
160+ }
161+ data , err := baseV3Call (runtime , "POST" ,
162+ baseV3Path ("bases" , runtime .Str ("base-token" ), "tables" , baseTableID (runtime ), "records" , "share_links" , "batch" ),
163+ nil , body )
164+ if err != nil {
165+ return err
166+ }
167+ runtime .Out (data , nil )
168+ return nil
169+ }
170+
171+ func executeRecordShare (runtime * common.RuntimeContext ) error {
172+ data , err := baseV3Call (runtime , "POST" ,
173+ baseV3Path ("bases" , runtime .Str ("base-token" ), "tables" , baseTableID (runtime ), "records" , runtime .Str ("record-id" ), "share_links" ),
174+ nil , nil )
175+ if err != nil {
176+ return err
177+ }
178+ runtime .Out (data , nil )
179+ return nil
180+ }
181+
115182func validateRecordJSON (runtime * common.RuntimeContext ) error {
116183 return nil
117184}
0 commit comments