PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: vmware/govmomi (go)

Issue:
Do we have an API to modify the name of a given datacenter?
Hi VMware team,

I am looking for a way to modify the name of existing datacenter. But there doesn't seem to have such API. I only found ReconfigureDatacenterRequestType that can be used by ReconfigureDatacenter_Task. However, there's no field as datacenter name in the request. Can we add support for this?



Pull request:
examples: add Common.Rename
Fixes #1736

Patch:
diff --git a/simulator/datacenter.go b/simulator/datacenter.go
index 7c563e38..e5028e9d 100644
--- a/simulator/datacenter.go
+++ b/simulator/datacenter.go
@@ -50,6 +50,10 @@ func NewDatacenter(f *Folder) *Datacenter {
 	return dc
 }
 
+func (dc *Datacenter) RenameTask(r *types.Rename_Task) soap.HasFault {
+	return RenameTask(dc, r)
+}
+
 // Create Datacenter Folders.
 // Every Datacenter has 4 inventory Folders: Vm, Host, Datastore and Network.
 // The ESX folder child types are limited to 1 type.


Test patch:
diff --git a/object/example_test.go b/object/example_test.go
index 27bb4252..eb14c3f3 100644
--- a/object/example_test.go
+++ b/object/example_test.go
@@ -294,6 +294,35 @@ func ExampleCommon_Destroy() {
 	// Output: destroyed /DC0/datastore/LocalDS_1
 }
 
+func ExampleCommon_Rename() {
+	model := simulator.VPX()
+
+	simulator.Run(func(ctx context.Context, c *vim25.Client) error {
+		dc, err := find.NewFinder(c).Datacenter(ctx, "DC0")
+		if err != nil {
+			return err
+		}
+
+		task, err := dc.Rename(ctx, "MyDC")
+		if err != nil {
+			return err
+		}
+
+		if err = task.Wait(ctx); err != nil {
+			return err
+		}
+
+		name, err := dc.ObjectName(ctx)
+		if err != nil {
+			return err
+		}
+
+		fmt.Println(name)
+		return nil
+	}, model)
+	// Output: MyDC
+}
+
 func ExampleCustomFieldsManager_Set() {
 	simulator.Run(func(ctx context.Context, c *vim25.Client) error {
 		m, err := object.GetCustomFieldsManager(c)