@@ -253,22 +253,50 @@ func (o *EntryObjectManager[E, T, S]) Delete(ctx context.Context, location T, pa
253
253
return nil
254
254
}
255
255
256
- func (o * EntryObjectManager [E , L , S ]) Update (ctx context.Context , location L , components []string , entry E , name string ) (E , error ) {
257
- xpath , err := location .XpathWithComponents (o .client .Versioning (), append (components , util .AsEntryXpath (name ))... )
256
+ func (o * EntryObjectManager [E , L , S ]) Update (ctx context.Context , location L , components []string , entry E , newName string ) (E , error ) {
257
+ updates := xmlapi .NewMultiConfig (2 )
258
+
259
+ var xpath , renamedXpath []string
260
+ var err error
261
+
262
+ spec , err := o .specifier (entry )
258
263
if err != nil {
259
264
return * new (E ), err
260
265
}
261
266
262
- err = o .service .UpdateWithXpath (ctx , util .AsXpath (xpath ), entry , name )
263
- if err != nil {
264
- if sdkerrors .IsObjectNotFound (err ) {
265
- return * new (E ), ErrObjectNotFound
266
- } else {
267
- return * new (E ), & Error {err : err , message : "sdk error while updating" }
267
+ xpath , err = location .XpathWithComponents (o .client .Versioning (), append (components , util .AsEntryXpath (entry .EntryName ()))... )
268
+ updates .Add (& xmlapi.Config {
269
+ Action : "edit" ,
270
+ Xpath : util .AsXpath (xpath ),
271
+ Element : spec ,
272
+ Target : o .client .GetTarget (),
273
+ })
274
+
275
+ if newName != "" {
276
+ renamedXpath , err = location .XpathWithComponents (o .client .Versioning (), append (components , util .AsEntryXpath (newName ))... )
277
+ _ , err = o .service .ReadWithXpath (ctx , util .AsXpath (renamedXpath ), "get" )
278
+ if err == nil {
279
+ return * new (E ), & Error {err : ErrConflict , message : fmt .Sprintf ("entry '%s' already exists" , newName )}
268
280
}
281
+
282
+ updates .Add (& xmlapi.Config {
283
+ Action : "rename" ,
284
+ Xpath : util .AsXpath (xpath ),
285
+ NewName : newName ,
286
+ Target : o .client .GetTarget (),
287
+ })
288
+ }
289
+
290
+ _ , _ , _ , err = o .client .MultiConfig (ctx , updates , false , nil )
291
+ if err != nil {
292
+ return * new (E ), err
269
293
}
270
294
271
- return o .service .ReadWithXpath (ctx , util .AsXpath (xpath ), "get" )
295
+ if renamedXpath != nil {
296
+ return o .service .ReadWithXpath (ctx , util .AsXpath (renamedXpath ), "get" )
297
+ } else {
298
+ return o .service .ReadWithXpath (ctx , util .AsXpath (xpath ), "get" )
299
+ }
272
300
}
273
301
274
302
func (o * EntryObjectManager [E , L , S ]) UpdateMany (ctx context.Context , location L , components []string , stateEntries []E , planEntries []E ) ([]E , error ) {
0 commit comments