1 package org.metricshub.wmi.windows.remote;
2
3 /*-
4 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
5 * WMI Java Client
6 * ჻჻჻჻჻჻
7 * Copyright (C) 2023 - 2025 MetricsHub
8 * ჻჻჻჻჻჻
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
21 */
22
23 import java.nio.charset.Charset;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.concurrent.TimeoutException;
27 import org.metricshub.wmi.exceptions.WindowsRemoteException;
28 import org.metricshub.wmi.exceptions.WqlQuerySyntaxException;
29
30 public interface WindowsRemoteExecutor extends AutoCloseable {
31 /**
32 * <p>Execute a WQL query and process its result.</p>
33 *
34 * @param wqlQuery the WQL query (required)
35 * @param timeout Timeout in milliseconds (throws an IllegalArgumentException if negative or zero)
36 * @return a list of result rows. A result row is a Map(LinkedHashMap to preserve the query order) of
37 * properties/values.
38 * @throws TimeoutException to notify userName of timeout.
39 * @throws WqlQuerySyntaxException if WQL query syntax is invalid
40 * @throws WindowsRemoteException For any problem encountered
41 */
42 List<Map<String, Object>> executeWql(String wqlQuery, long timeout)
43 throws TimeoutException, WqlQuerySyntaxException, WindowsRemoteException;
44
45 /**
46 * Execute the command on the remote
47 * @param command The command to execute
48 * @param workingDirectory Path of the directory for the spawned process on the remote system (can be null)
49 * @param charset The charset
50 * @param timeout Timeout in milliseconds
51 * @return The command result
52 * @throws WindowsRemoteException For any problem encountered
53 * @throws TimeoutException To notify userName of timeout.
54 */
55 WindowsRemoteCommandResult executeCommand(String command, String workingDirectory, Charset charset, long timeout)
56 throws WindowsRemoteException, TimeoutException;
57
58 /**
59 * Get the hostname.
60 * @return
61 */
62 String getHostname();
63
64 /**
65 * Get the username.
66 * @return
67 */
68 String getUsername();
69
70 /**
71 * Get the password.
72 * @return
73 */
74 char[] getPassword();
75 }