use of org.ovirt.engine.sdk4.types.Role in project ovirt-engine-sdk-java by oVirt.
the class AddSystemPermission method main.
public static void main(String[] args) throws Exception {
// Create the connection to the server:
Connection connection = connection().url("https://engine40.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").trustStoreFile("truststore.jks").build();
// Get the reference to the root of the tree of services:
SystemService systemService = connection.systemService();
// Get the reference to the service that manages system permissions:
SystemPermissionsService permissionsService = systemService.permissionsService();
// Add the "SupeUser" permission to the user with id "123":
permissionsService.add().permission(permission().role(role().name("SuperUser")).user(user().id("123"))).send();
// Close the connection to the server:
connection.close();
}
use of org.ovirt.engine.sdk4.types.Role in project ovirt-engine-sdk-java by oVirt.
the class FollowVmLinks method main.
public static void main(String[] args) throws Exception {
// Create the connection to the server:
Connection connection = connection().url("https://engine40.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").trustStoreFile("truststore.jks").build();
// Get the reference to the service that manages virtual machines:
VmsService vmsService = connection.systemService().vmsService();
// Find the virtual machine:
Vm vm = vmsService.list().search("name=myvm").send().vms().get(0);
// When the server returns a virtual machine it will return links to related objects, like the cluster,
// template and permissions something like this:
//
// <link href="/api/vms/123/permissions" rel="permissions"/>
// ...
// <cluster id="123" href="/api/clusters/123"/>
// <template id="456" href="/api/templates/456"/>
//
// The SDK provides a "followLink" method that can be used to retrieve the complete content of these related
// objects.
Cluster cluster = connection.followLink(vm.cluster());
Template template = connection.followLink(vm.template());
List<Permission> permissions = connection.followLink(vm.permissions());
// Now we can use the details of the cluster, template and permissions:
System.out.printf("cluster: %s\n", cluster.name());
System.out.printf("template: %s\n", template.name());
for (Permission permission : permissions) {
System.out.printf("role: %s\n", permission.role().id());
}
// Close the connection to the server:
connection.close();
}
use of org.ovirt.engine.sdk4.types.Role in project ovirt-engine-sdk-java by oVirt.
the class ListRoles method main.
public static void main(String[] args) throws Exception {
// Create the connection to the server:
Connection connection = connection().url("https://engine41.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").trustStoreFile("truststore.jks").build();
// Get the reference to the service that manages the roles:
RolesService rolesService = connection.systemService().rolesService();
// Retrieve the roles:
List<Role> roles = rolesService.list().send().roles();
// For each role print its name and description:
for (Role role : roles) {
System.out.printf("%s: %s\n", role.name(), role.description());
}
// Close the connection to the server:
connection.close();
}
Aggregations