2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.freeboxos.internal.api.rest;
15 import static org.openhab.binding.freeboxos.internal.FreeboxOsBindingConstants.THING_VM;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.freeboxos.internal.api.FreeboxException;
19 import org.openhab.binding.freeboxos.internal.api.Response;
21 import inet.ipaddr.mac.MACAddress;
24 * The {@link VmManager} is the Java class used to handle api requests related to virtual machines
26 * @author Gaƫl L'hopital - Initial contribution
29 public class VmManager extends ListableRest<VmManager.VirtualMachine, VmManager.VirtualMachineResponse> {
31 protected class VirtualMachineResponse extends Response<VirtualMachine> {
40 public static record VirtualMachine(int id, String name, MACAddress mac, Status status) {
43 public VmManager(FreeboxOsSession session) throws FreeboxException {
44 super(session, LoginManager.Permission.VM, VirtualMachineResponse.class,
45 session.getUriBuilder().path(THING_VM));
48 public void power(int vmId, boolean startIt) throws FreeboxException {
49 post(Integer.toString(vmId), startIt ? "start" : "powerbutton");