1 /*
2  * DesktopJobLauncherOverlay.hpp
3  *
4  * Copyright (C) 2021 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant
7  * to the terms of a commercial license agreement with RStudio, then
8  * this program is licensed to you under the terms of version 3 of the
9  * GNU Affero General Public License. This program is distributed WITHOUT
10  * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
12  * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13  *
14  */
15 
16 #ifndef DESKTOP_JOB_LAUNCHER_OVERLAY_HPP
17 #define DESKTOP_JOB_LAUNCHER_OVERLAY_HPP
18 
19 #include <string>
20 
21 #include <QNetworkCookie>
22 
23 #include <core/http/AsyncClient.hpp>
24 #include <shared_core/json/Json.hpp>
25 
26 #include "DesktopMainWindow.hpp"
27 #include "DesktopSessionServersOverlay.hpp"
28 
29 namespace rstudio {
30 namespace desktop {
31 
32 class JobLauncherImpl;
33 
34 class JobLauncher
35 {
36 public:
37     explicit JobLauncher(MainWindow* pMainWindow);
38 
39     core::Error initialize();
40 
41     void startLauncherJobStatusStream(const std::string& jobId);
42 
43     void stopLauncherJobStatusStream(const std::string& jobId);
44 
45     void startLauncherJobOutputStream(const std::string& jobId);
46 
47     void stopLauncherJobOutputStream(const std::string& jobId);
48 
49     void controlLauncherJob(const std::string& jobId,
50                             const std::string& operation);
51 
52     void submitLauncherJob(const core::json::Object& jobObj);
53 
54     void validateJobsConfig();
55 
56     void getJobContainerUser();
57 
58     bool setSessionServer(const SessionServer& sessionServer);
59 
60     void signIn();
61 
62     int getProxyPortNumber();
63 
64     SessionServer getLauncherServer();
65 
66     std::map<std::string, QNetworkCookie> getCookies();
67 
68 private:
69     boost::shared_ptr<JobLauncherImpl> pImpl_;
70 };
71 
72 
73 } // namespace desktop
74 } // namespace rstudio
75 
76 #endif // DESKTOP_JOB_LAUNCHER_OVERLAY_HPP
77 
78