Search

2.11. Modifying Sub-Resources

download PDF
The following example outlines how to modify sub-resources. In this example, the name of a disk with the name 'test_Disk1' belonging to a virtual machine with the name 'test' is changed to 'test_Disk1_updated'.

Procedure 2.7. Updating a Sub-Resource

  1. Declare an instance of the resource whose sub-resource is to be modified:
    VM vm = api.getVMs().get("test");
  2. Declare an instance of the sub-resource to be modified:
    VMDisk disk = vm.getDisks().get("test_Disk1");
  3. Set the new value of the attribute:
    disk.setAlias("test_Disk1_updated");
  4. Update the sub-resource:
    VMDisk updateDisk = disk.update();
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.