diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d16077a --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +**/nbproject/private/ +**/nbproject/Makefile-*.mk +**/nbproject/Package-*.bash +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8584cbc --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +ActivityWatchLogo + +# AwWatcherNetBeans82 + +This extension allows [ActivityWatch](https://activitywatch.net), the free and open-source time tracker, to keep track of the projects and programming languages you use in NetBeans IDE. + +## Features + +Sends following data to ActivityWatch: +- current project name +- current file name +- programming language (by current file extension) + +## Requirements + +This extension requires ActivityWatch to be running on your machine. + +## Installation + +1. Download the `.nbm` plugin from [GitHub releases](https://github.com/pytlus93/AwWatcherNetBeans82/releases/latest). + +2. Inside your IDE, select `Tools` -> `Plugins` -> `Downloaded` -> `Add Plugins...` + +3. Select the downloaded nbm file. + +4. Check `AwWatcherNetBeans` and click the `Install` button. + +5. Follow the wizard instructions to complete the installation. + +6. Use your IDE like you normally do and your time will be tracked for you automatically. + +7. Visit [http://localhost:5600](http://localhost:5600) to see your logged time. + +## Extension Settings + +![Configuration Dialog](/assets/images/ConfigDialog.png) + +- Frequency + - Allows to setup frequency of sending [hearbeats](https://docs.activitywatch.net/en/latest/buckets-and-events.html#heartbeats) in range <1;60>\ +Default: 5s + +- Pulse time + - Allows to setup Pulse Time (size of timewindow between events that will be merged in one event) in range <1;120>\ +Default: 20s + +- Debug mode + - Allows to use Activity Watch test mode, it means use testing server url `localhost:5666` instead of `localhost:5600`\ +Default: False + +- Custom File Types + - Allows to define custom defined languages or reassing file extension to another language.\ +Enter file extension and corresponding language in format `=` one per line. + - Examples: + - IFS Development + ``` + entity=IFS Marble Entity + enumeration=IFS Marble Entity + utility=IFS Marble Entity + storage=IFS Marble Entity + views=IFS Marble Entity + serverpackage=IFS Marble Middle-Tier + report=IFS Report + rdf=IFS Report + cdb=IFS PL/SQL + ins=IFS PL/SQL + cre=IFS PL/SQL + ``` + +## Development + +### API Client + +Client is generated from [Swagger definition](http://localhost:5600/api/swagger.json) via SwaggerHub ([My project for ActivityWatch REST API v1.0](https://app.swaggerhub.com/apis/InfFilipV/ActivityWatch/1.0)). + + +## Special Thanks + +- [netbeans-wakatime](https://github.com/wakatime/netbeans-wakatime) +- [aw-watcher-vscode](https://github.com/ActivityWatch/aw-watcher-vscode/) + +## Release Notes + +### 1.0.0 + +First version \ No newline at end of file diff --git a/assets/images/ConfigDialog.png b/assets/images/ConfigDialog.png new file mode 100644 index 0000000..e03838b Binary files /dev/null and b/assets/images/ConfigDialog.png differ diff --git a/assets/images/logo.png b/assets/images/logo.png new file mode 100644 index 0000000..d5e59a6 Binary files /dev/null and b/assets/images/logo.png differ diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..161d9f0 --- /dev/null +++ b/build.xml @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project com.github.pytlus93.AwWatcherNetBeans. + + diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..96b2882 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +AutoUpdate-Show-In-Client: true +OpenIDE-Module: com.github.pytlus93.AwWatcherNetBeans/1 +OpenIDE-Module-Install: com/github/pytlus93/AwWatcherNetBeans/AwWatcherNetBeans.class +OpenIDE-Module-Localizing-Bundle: com/github/pytlus93/AwWatcherNetBeans/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..1121b31 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..bc5ed39 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=9169c787 +build.xml.script.CRC32=b729be5a +build.xml.stylesheet.CRC32=a56c6a5b@2.72.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=9169c787 +nbproject/build-impl.xml.script.CRC32=b64a7c09 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.72.1 diff --git a/nbproject/platform.properties b/nbproject/platform.properties new file mode 100644 index 0000000..42f08c5 --- /dev/null +++ b/nbproject/platform.properties @@ -0,0 +1,17 @@ +cluster.path=\ + ${nbplatform.active.dir}/apisupport:\ + ${nbplatform.active.dir}/developer_studio:\ + ${nbplatform.active.dir}/enterprise:\ + ${nbplatform.active.dir}/ergonomics:\ + ${nbplatform.active.dir}/extide:\ + ${nbplatform.active.dir}/extra:\ + ${nbplatform.active.dir}/harness:\ + ${nbplatform.active.dir}/ide:\ + ${nbplatform.active.dir}/java:\ + ${nbplatform.active.dir}/nb:\ + ${nbplatform.active.dir}/platform:\ + ${nbplatform.active.dir}/profiler:\ + ${nbplatform.active.dir}/webcommon:\ + ${nbplatform.active.dir}/websvccommon +nbjdk.active=default +nbplatform.active=default diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..333bb63 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,12 @@ +auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml +file.reference.gson-2.8.6.jar=release/modules/ext/gson-2.8.6.jar +file.reference.gson-fire-1.8.5.jar=release/modules/ext/gson-fire-1.8.5.jar +file.reference.logging-interceptor-2.7.5.jar=release/modules/ext/logging-interceptor-2.7.5.jar +file.reference.okhttp-2.7.5.jar=release/modules/ext/okhttp-2.7.5.jar +file.reference.okio-1.6.0.jar=release/modules/ext/okio-1.6.0.jar +file.reference.swagger-annotations-1.6.4.jar=release/modules/ext/swagger-annotations-1.6.4.jar +file.reference.threetenbp-1.5.2.jar=release/modules/ext/threetenbp-1.5.2.jar +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial +nbm.homepage=https://github.com/pytlus93/AwWatcherNetBeans82 +nbm.module.author=Filip Vrba diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..911b5f3 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,133 @@ + + + org.netbeans.modules.apisupport.project + + + com.github.pytlus93.AwWatcherNetBeans + + + + org.netbeans.modules.editor.lib2 + + + + 1 + 2.16.1.55.3 + + + + org.netbeans.modules.options.api + + + + 1 + 1.45.1 + + + + org.netbeans.modules.parsing.api + + + + 1 + 9.6.1.8 + + + + org.netbeans.modules.projectapi + + + + 1 + 1.66.1 + + + + org.openide.awt + + + + 7.67.1 + + + + org.openide.filesystems + + + + 9.10.1 + + + + org.openide.modules + + + + 7.48.1 + + + + org.openide.util + + + + 9.7.1 + + + + org.openide.util.lookup + + + + 8.33.1 + + + + org.openide.util.ui + + + + 9.6.1 + + + + org.openide.windows + + + + 6.75.1 + + + + + + ext/swagger-annotations-1.6.4.jar + release/modules/ext/swagger-annotations-1.6.4.jar + + + ext/gson-fire-1.8.5.jar + release/modules/ext/gson-fire-1.8.5.jar + + + ext/gson-2.8.6.jar + release/modules/ext/gson-2.8.6.jar + + + ext/threetenbp-1.5.2.jar + release/modules/ext/threetenbp-1.5.2.jar + + + ext/logging-interceptor-2.7.5.jar + release/modules/ext/logging-interceptor-2.7.5.jar + + + ext/okhttp-2.7.5.jar + release/modules/ext/okhttp-2.7.5.jar + + + ext/okio-1.6.0.jar + release/modules/ext/okio-1.6.0.jar + + + + diff --git a/release/modules/ext/gson-2.8.6.jar b/release/modules/ext/gson-2.8.6.jar new file mode 100644 index 0000000..4765c4a Binary files /dev/null and b/release/modules/ext/gson-2.8.6.jar differ diff --git a/release/modules/ext/gson-fire-1.8.5.jar b/release/modules/ext/gson-fire-1.8.5.jar new file mode 100644 index 0000000..f600e87 Binary files /dev/null and b/release/modules/ext/gson-fire-1.8.5.jar differ diff --git a/release/modules/ext/logging-interceptor-2.7.5.jar b/release/modules/ext/logging-interceptor-2.7.5.jar new file mode 100644 index 0000000..444a41f Binary files /dev/null and b/release/modules/ext/logging-interceptor-2.7.5.jar differ diff --git a/release/modules/ext/okhttp-2.7.5.jar b/release/modules/ext/okhttp-2.7.5.jar new file mode 100644 index 0000000..e6df064 Binary files /dev/null and b/release/modules/ext/okhttp-2.7.5.jar differ diff --git a/release/modules/ext/okio-1.6.0.jar b/release/modules/ext/okio-1.6.0.jar new file mode 100644 index 0000000..c87be59 Binary files /dev/null and b/release/modules/ext/okio-1.6.0.jar differ diff --git a/release/modules/ext/swagger-annotations-1.6.4.jar b/release/modules/ext/swagger-annotations-1.6.4.jar new file mode 100644 index 0000000..966c447 Binary files /dev/null and b/release/modules/ext/swagger-annotations-1.6.4.jar differ diff --git a/release/modules/ext/swagger-java-client-1.0.0.jar b/release/modules/ext/swagger-java-client-1.0.0.jar new file mode 100644 index 0000000..1d9739e Binary files /dev/null and b/release/modules/ext/swagger-java-client-1.0.0.jar differ diff --git a/release/modules/ext/threetenbp-1.5.2.jar b/release/modules/ext/threetenbp-1.5.2.jar new file mode 100644 index 0000000..91a6866 Binary files /dev/null and b/release/modules/ext/threetenbp-1.5.2.jar differ diff --git a/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherNetBeans.java b/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherNetBeans.java new file mode 100644 index 0000000..31175c9 --- /dev/null +++ b/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherNetBeans.java @@ -0,0 +1,275 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.github.pytlus93.AwWatcherNetBeans; + +import io.swagger.client.ApiException; +import io.swagger.client.api.DefaultApi; +import io.swagger.client.model.CreateBucket; +import io.swagger.client.model.Event; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; +import java.util.Scanner; +import java.util.logging.Logger; +import java.util.prefs.Preferences; +import javax.swing.text.Document; +import javax.swing.text.JTextComponent; +import org.netbeans.api.editor.EditorRegistry; +import org.netbeans.api.project.Project; +import org.netbeans.api.project.ProjectUtils; +import org.openide.filesystems.FileObject; +import org.openide.modules.ModuleInstall; +import org.openide.util.Exceptions; +import org.openide.util.NbPreferences; +import org.openide.windows.OnShowing; +import org.threeten.bp.OffsetDateTime; + +/** + * + * @author FiVrCz + */ +@OnShowing +public class AwWatcherNetBeans extends ModuleInstall implements Runnable { + + private static final String CLIENT_ID = "aw-watcher-netbeans"; + private static final String HOSTNAME = getComputerName(); + + private static final Logger log = Logger.getLogger("AwWatcherNetBeans"); + private static DefaultApi awAPI; + private static String bucketId; + + private static int frequency; + private static int pulseTime; + + public static String lastFile = null; + private static OffsetDateTime actionStart = null; + private static OffsetDateTime lastTime = null; + + public static CustomDocumentListener documentListener; + + @Override + public void run() { + awAPI = new DefaultApi(); + applySettings(); + + PropertyChangeListener pcl = new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + JTextComponent jtc = EditorRegistry.lastFocusedComponent(); + if (jtc != null) { + Document d = jtc.getDocument(); + if (d != null) { + CustomDocumentListener listener = new CustomDocumentListener(d); + d.addDocumentListener(listener); + listener.update(); + listener.handleChange(); + } + } + } + }; + + EditorRegistry.addPropertyChangeListener(pcl); + + //runCycleFileChecking(); + } + + public static void applySettings() { + Preferences prefs = NbPreferences.forModule(AwWatcherNetBeans.class); + + if (prefs.getBoolean("Debug", false)) { + awAPI.getApiClient().setBasePath("http://localhost:5666/api"); + } else { + awAPI.getApiClient().setBasePath("http://localhost:5600/api"); + } + + frequency = prefs.getInt("Frequency", 5); + pulseTime = prefs.getInt("PulseTime", 20); + + custExts.clear(); + for (String line : prefs.get("CustomFileTypes", "").trim().split("\\r?\\n")) { + String[] parts = line.trim().split("=", -1); + if (parts.length == 2) { + custExts.put(parts[0], parts[1]); + } + } + + bucketId = CLIENT_ID + "_" + getComputerName(); + for (int i = 0; i < 5; i++) { + if (createBucket()) { + break; + } + try { + Thread.sleep(1000); + } catch (InterruptedException ex) { + log.warning(ex.getLocalizedMessage()); + } + } + } + +// @SuppressWarnings("SleepWhileInLoop") +// private void runCycleFileChecking() { +// while (true) { +// TopComponent activeTC = TopComponent.getRegistry().getActivated(); +// if (activeTC == null) { +// continue; +// } +// DataObject dataLookup = activeTC.getLookup().lookup(DataObject.class); +// if (dataLookup == null) { +// continue; +// } +// final FileObject file = dataLookup.getPrimaryFile(); +// if (file == null) { +// continue; +// } +// final Project project = FileOwnerQuery.getOwner(file); +// sendHeartbeat(OffsetDateTime.now(), file, project, false); +// try { +// Thread.sleep(FREQUENCY * 1000); +// } catch (InterruptedException ignored) { +// } +// } +// } + private static boolean createBucket() { + try { + awAPI.getBucketResource(bucketId); + return true; + } catch (ApiException ex) { + switch (ex.getCode()) { + case 404: + CreateBucket cb = new CreateBucket(); + cb.setClient(CLIENT_ID); + cb.setHostname(HOSTNAME); + cb.setType("app.editor.activity"); + { + try { + awAPI.postBucketResource(bucketId, cb); + return true; + } catch (ApiException ex1) { + log.warning(ex1.getLocalizedMessage()); + } + } + break; + default: + log.warning(ex.getLocalizedMessage()); + } + } + return false; + } + + public static boolean enoughTimePassed(OffsetDateTime currentTime) { + return AwWatcherNetBeans.lastTime.plusSeconds(frequency).isBefore(currentTime); + } + + private static void sendHeartbeat(Event e) throws ApiException { + awAPI.postHeartbeatResource(bucketId, e, Integer.toString(pulseTime)); + } + + private static String getComputerName() { + Map env = System.getenv(); + if (env.containsKey("COMPUTERNAME")) { + return env.get("COMPUTERNAME"); + } else if (env.containsKey("HOSTNAME")) { + return env.get("HOSTNAME"); + } else { + return "Unknown Computer"; + } + } + + public static void sendHeartbeat(final OffsetDateTime currentTime, final FileObject file, final Project currentProject) { + sendHeartbeat(currentTime, file, currentProject, 0); + } + + public static void sendHeartbeat(final OffsetDateTime currentTime, final FileObject file, final Project currentProject, final int tries) { + Runnable r = new Runnable() { + @Override + public void run() { + try { + Event e = new Event(); + e.setTimestamp(currentTime); + EditorData ed = new EditorData(); + ed.file = file == null ? null : file.getPath(); + ed.project = currentProject == null ? null : ProjectUtils.getInformation(currentProject).getDisplayName(); + ed.language = getLanguage(file); + if (file == null ? AwWatcherNetBeans.lastFile != null : !file.getPath().equals(AwWatcherNetBeans.lastFile)) { + AwWatcherNetBeans.lastFile = file == null ? null : file.getPath(); + AwWatcherNetBeans.actionStart = currentTime; + AwWatcherNetBeans.lastTime = currentTime; + } + e.setDuration(BigDecimal.ZERO); + //e.setDuration(BigDecimal.valueOf(org.threeten.bp.Duration.between(lastTime, currentTime).getSeconds())); + e.setData(ed); + AwWatcherNetBeans.sendHeartbeat(e); + } catch (ApiException e) { + if (tries < 3) { + log.fine(e.toString()); + try { + Thread.sleep(30); + } catch (InterruptedException e1) { + log.warning(e1.toString()); + } + sendHeartbeat(currentTime, file, currentProject, tries + 1); + return; + } else { + log.warning(e.toString()); + return; + } + } + lastTime = currentTime; + } + }; + new Thread(r).start(); + } + + private static String getLanguage(FileObject file) { + if (file == null) { + return null; + } + String fileName = file.getNameExt().toLowerCase(); + + String result = findLanguage(fileName); + + if (result == null && fileName.endsWith(".bak")) { + fileName = fileName.substring(0, fileName.length() - 4); + result = findLanguage(fileName); + } + + return result != null ? result : file.getExt(); + } + + private static String findLanguage(final String inFileName) { + String fileName = inFileName; + String result = custExts.getOrDefault(fileName, exts.get(fileName)); + while (result == null) { + int dotPos = fileName.indexOf("."); + if (dotPos == -1) { + break; + } + fileName = fileName.substring(dotPos + 1); + result = custExts.getOrDefault(fileName, exts.get(fileName)); + } + return result; + } + + private static final Map exts = new HashMap(); + private static final Map custExts = new HashMap(); + + static { + try { + exts.clear(); + InputStream is = AwWatcherNetBeans.class.getResourceAsStream("/com/github/pytlus93/AwWatcherNetBeans/exts.ini"); + String text = new Scanner(is, "UTF-8").useDelimiter("\\A").next(); + for (String line : text.split("\\n")) { + String[] parts = line.trim().split("="); + exts.put(parts[0].trim(), parts[1].trim()); + } + } catch (Exception ex) { + Exceptions.printStackTrace(ex); + } + } +} diff --git a/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherOptionsPanel.form b/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherOptionsPanel.form new file mode 100644 index 0000000..cf72123 --- /dev/null +++ b/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherOptionsPanel.form @@ -0,0 +1,181 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherOptionsPanel.java b/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherOptionsPanel.java new file mode 100644 index 0000000..1270d51 --- /dev/null +++ b/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherOptionsPanel.java @@ -0,0 +1,223 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.github.pytlus93.AwWatcherNetBeans; + +import java.util.HashMap; +import java.util.Map; +import java.util.prefs.Preferences; +import org.openide.util.NbPreferences; + +/** + * + * @author FiVrCz + */ +public class AwWatcherOptionsPanel extends javax.swing.JPanel { + + private final AwWatcherOptionsPanelController controller; + + AwWatcherOptionsPanel(AwWatcherOptionsPanelController controller) { + this.controller = controller; + initComponents(); + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + lblFrequency = new javax.swing.JLabel(); + spFrequency = new javax.swing.JSpinner(); + lblPulseTime = new javax.swing.JLabel(); + spPulseTime = new javax.swing.JSpinner(); + cbDebug = new javax.swing.JCheckBox(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + taCustomFiletypes = new javax.swing.JTextArea(); + lblCustomFiletypes = new javax.swing.JLabel(); + + lblFrequency.setLabelFor(spFrequency); + org.openide.awt.Mnemonics.setLocalizedText(lblFrequency, org.openide.util.NbBundle.getMessage(AwWatcherOptionsPanel.class, "AwWatcherOptionsPanel.lblFrequency.text")); // NOI18N + lblFrequency.setToolTipText(org.openide.util.NbBundle.getMessage(AwWatcherOptionsPanel.class, "AwWatcherOptionsPanel.lblFrequency.toolTipText")); // NOI18N + + spFrequency.setModel(new javax.swing.SpinnerNumberModel(5, 1, 60, 1)); + spFrequency.addPropertyChangeListener(new java.beans.PropertyChangeListener() { + public void propertyChange(java.beans.PropertyChangeEvent evt) { + someFieldPropertyChanged(evt); + } + }); + + lblPulseTime.setLabelFor(spPulseTime); + org.openide.awt.Mnemonics.setLocalizedText(lblPulseTime, org.openide.util.NbBundle.getMessage(AwWatcherOptionsPanel.class, "AwWatcherOptionsPanel.lblPulseTime.text")); // NOI18N + lblPulseTime.setToolTipText(org.openide.util.NbBundle.getMessage(AwWatcherOptionsPanel.class, "AwWatcherOptionsPanel.lblPulseTime.toolTipText")); // NOI18N + + spPulseTime.setModel(new javax.swing.SpinnerNumberModel(20, 1, 120, 1)); + spPulseTime.addPropertyChangeListener(new java.beans.PropertyChangeListener() { + public void propertyChange(java.beans.PropertyChangeEvent evt) { + someFieldPropertyChanged(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(cbDebug, org.openide.util.NbBundle.getMessage(AwWatcherOptionsPanel.class, "AwWatcherOptionsPanel.cbDebug.text")); // NOI18N + cbDebug.setToolTipText(org.openide.util.NbBundle.getMessage(AwWatcherOptionsPanel.class, "AwWatcherOptionsPanel.cbDebug.toolTipText")); // NOI18N + cbDebug.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); + cbDebug.addPropertyChangeListener(new java.beans.PropertyChangeListener() { + public void propertyChange(java.beans.PropertyChangeEvent evt) { + someFieldPropertyChanged(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(AwWatcherOptionsPanel.class, "AwWatcherOptionsPanel.jLabel1.text")); // NOI18N + jLabel1.setFocusable(false); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(AwWatcherOptionsPanel.class, "AwWatcherOptionsPanel.jLabel2.text")); // NOI18N + jLabel2.setFocusable(false); + + taCustomFiletypes.setColumns(20); + taCustomFiletypes.setRows(10); + taCustomFiletypes.setTabSize(3); + taCustomFiletypes.setToolTipText(org.openide.util.NbBundle.getMessage(AwWatcherOptionsPanel.class, "AwWatcherOptionsPanel.taCustomFiletypes.toolTipText")); // NOI18N + taCustomFiletypes.addPropertyChangeListener(new java.beans.PropertyChangeListener() { + public void propertyChange(java.beans.PropertyChangeEvent evt) { + someFieldPropertyChanged(evt); + } + }); + jScrollPane1.setViewportView(taCustomFiletypes); + + org.openide.awt.Mnemonics.setLocalizedText(lblCustomFiletypes, org.openide.util.NbBundle.getMessage(AwWatcherOptionsPanel.class, "AwWatcherOptionsPanel.lblCustomFiletypes.text")); // NOI18N + lblCustomFiletypes.setToolTipText(org.openide.util.NbBundle.getMessage(AwWatcherOptionsPanel.class, "AwWatcherOptionsPanel.lblCustomFiletypes.toolTipText")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(lblFrequency) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(spFrequency, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel1) + .addGap(18, 18, 18) + .addComponent(lblPulseTime) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(spPulseTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2) + .addGap(26, 26, 26) + .addComponent(cbDebug)) + .addComponent(lblCustomFiletypes)) + .addGap(0, 23, Short.MAX_VALUE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lblFrequency) + .addComponent(spFrequency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1) + .addComponent(lblPulseTime) + .addComponent(spPulseTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2) + .addComponent(cbDebug)) + .addGap(18, 18, 18) + .addComponent(lblCustomFiletypes) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + private void someFieldPropertyChanged(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_someFieldPropertyChanged + this.controller.changed(); + }//GEN-LAST:event_someFieldPropertyChanged + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox cbDebug; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel lblCustomFiletypes; + private javax.swing.JLabel lblFrequency; + private javax.swing.JLabel lblPulseTime; + private javax.swing.JSpinner spFrequency; + private javax.swing.JSpinner spPulseTime; + private javax.swing.JTextArea taCustomFiletypes; + // End of variables declaration//GEN-END:variables + + private String lastCustomFileTypes; + private boolean lastResult; + + boolean valid() { + if (!(spFrequency.getValue() instanceof Integer) || !(spPulseTime.getValue() instanceof Integer)) { + return false; + } + + if (taCustomFiletypes.getText().equals(lastCustomFileTypes)) { + return lastResult; + } + + lastCustomFileTypes = taCustomFiletypes.getText(); + + if (lastCustomFileTypes.isEmpty()) { + return lastResult = true; + + } + Map exts = new HashMap(); + for (String line : taCustomFiletypes.getText().trim().split("\\r?\\n", -1)) { + if (line.isEmpty()) { + return lastResult = false; + } + String[] parts = line.trim().split("=", -1); + if (parts.length != 2) { + return lastResult = false; + } + if (exts.containsKey(parts[0])) { + return lastResult = false; + } + exts.put(parts[0], parts[1]); + } + return lastResult = true; + } + + void store() { + Preferences prefs = NbPreferences.forModule(AwWatcherNetBeans.class); + prefs.putBoolean("Debug", this.cbDebug.isSelected()); + prefs.putInt("Frequency", (int) spFrequency.getValue()); + prefs.putInt("PulseTime", (int) spPulseTime.getValue()); + prefs.put("CustomFileTypes", taCustomFiletypes.getText()); + } + + void load() { + Preferences prefs = NbPreferences.forModule(AwWatcherNetBeans.class); + this.cbDebug.setSelected(prefs.getBoolean("Debug", false)); + this.spFrequency.setValue(prefs.getInt("Frequency", 5)); + this.spPulseTime.setValue(prefs.getInt("PulseTime", 20)); + this.taCustomFiletypes.setText(prefs.get("CustomFileTypes", "")); + } + + private static boolean isInteger(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException nfe) { + return false; + } + } +} diff --git a/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherOptionsPanelController.java b/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherOptionsPanelController.java new file mode 100644 index 0000000..ed60d07 --- /dev/null +++ b/src/com/github/pytlus93/AwWatcherNetBeans/AwWatcherOptionsPanelController.java @@ -0,0 +1,97 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.github.pytlus93.AwWatcherNetBeans; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import javax.swing.JComponent; +import javax.swing.SwingUtilities; +import org.netbeans.spi.options.OptionsPanelController; +import org.openide.util.HelpCtx; +import org.openide.util.Lookup; + +@OptionsPanelController.TopLevelRegistration( + categoryName = "#OptionsCategory_Name_AwWatcherNetBeans", + iconBase = "com/github/pytlus93/AwWatcherNetBeans/logo_32.png", + keywords = "#OptionsCategory_Keywords_AwWatcherNetBeans", + keywordsCategory = "AwWatcherNetBeans" +) +@org.openide.util.NbBundle.Messages({"OptionsCategory_Name_AwWatcherNetBeans=Activity Watcher", "OptionsCategory_Keywords_AwWatcherNetBeans=activity,watch,activitywatch,aw,watcher"}) +public final class AwWatcherOptionsPanelController extends OptionsPanelController { + + private AwWatcherOptionsPanel panel; + private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); + private boolean changed; + + @Override + public void update() { + getPanel().load(); + changed = false; + } + + @Override + public void applyChanges() { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + getPanel().store(); + AwWatcherNetBeans.applySettings(); + changed = false; + } + }); + } + + @Override + public void cancel() { + //reset to default + update(); + } + + @Override + public boolean isValid() { + return getPanel().valid(); + } + + @Override + public boolean isChanged() { + return changed; + } + + @Override + public HelpCtx getHelpCtx() { + return null; + } + + @Override + public JComponent getComponent(Lookup masterLookup) { + return getPanel(); + } + + @Override + public void addPropertyChangeListener(PropertyChangeListener l) { + pcs.addPropertyChangeListener(l); + } + + @Override + public void removePropertyChangeListener(PropertyChangeListener l) { + pcs.removePropertyChangeListener(l); + } + + private AwWatcherOptionsPanel getPanel() { + if (panel == null) { + panel = new AwWatcherOptionsPanel(this); + } + return panel; + } + + void changed() { + if (!changed) { + changed = true; + pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true); + } + pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null); + } +} diff --git a/src/com/github/pytlus93/AwWatcherNetBeans/Bundle.properties b/src/com/github/pytlus93/AwWatcherNetBeans/Bundle.properties new file mode 100644 index 0000000..a3d5a49 --- /dev/null +++ b/src/com/github/pytlus93/AwWatcherNetBeans/Bundle.properties @@ -0,0 +1,17 @@ +OpenIDE-Module-Display-Category=Time Tracker +OpenIDE-Module-Long-Description=\ + This extension allows Activity Watch (https://activitywatch.net), the free and open-source time tracker, to keep track of the projects and programming languages you use in NetBeans IDE.\n\n\ + Sends following data to ActivityWatch:\n- current project name\n- current file name\n- programming language (by current file extension)\n\nhttps://github.com/pytlus93/AwWatcherNetBeans82 +OpenIDE-Module-Name=AwWatcherNetBeans +AwWatcherOptionsPanel.lblCustomFiletypes.text=Custom File Types +AwWatcherOptionsPanel.taCustomFiletypes.toolTipText=Enter file extension and corresponding language in format "=" one per line +AwWatcherOptionsPanel.jLabel2.text=s +AwWatcherOptionsPanel.jLabel1.text=s +AwWatcherOptionsPanel.lblPulseTime.toolTipText=Largest timewindow allowed between heartbeats for them to merge +AwWatcherOptionsPanel.lblPulseTime.text=Pulse time +AwWatcherOptionsPanel.lblFrequency.text=Frequency +AwWatcherOptionsPanel.lblCustomFiletypes.toolTipText=Enter file extension and corresponding language in format "=" one per line +AwWatcherOptionsPanel.cbDebug.toolTipText=Use localhost:5666 instead of localhost:5600 +AwWatcherOptionsPanel.cbDebug.text=Debug mode +OpenIDE-Module-Short-Description=This extension allows Activity Watch (https://activitywatch.net), the free and open-source time tracker, to keep track of the projects and programming languages you use in NetBeans IDE. +AwWatcherOptionsPanel.lblFrequency.toolTipText=Frequency of sending Heartbeats diff --git a/src/com/github/pytlus93/AwWatcherNetBeans/CustomDocumentListener.java b/src/com/github/pytlus93/AwWatcherNetBeans/CustomDocumentListener.java new file mode 100644 index 0000000..beb344e --- /dev/null +++ b/src/com/github/pytlus93/AwWatcherNetBeans/CustomDocumentListener.java @@ -0,0 +1,94 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.github.pytlus93.AwWatcherNetBeans; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.Document; +import org.netbeans.api.project.FileOwnerQuery; +import org.netbeans.api.project.Project; +import org.netbeans.modules.parsing.api.Source; +import org.openide.filesystems.FileObject; +import org.threeten.bp.OffsetDateTime; + +/** + * + * @author alanhamlett + */ +public class CustomDocumentListener implements DocumentListener { + + private final Document document; + + public CustomDocumentListener(Document d) { + this.document = d; + } + + @Override + public void insertUpdate(DocumentEvent e) { + this.handleChange(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + this.handleChange(); + } + + @Override + public void changedUpdate(DocumentEvent e) { + this.handleChange(); + } + + public void update() { + if (AwWatcherNetBeans.documentListener != null) { + AwWatcherNetBeans.documentListener.remove(); + } + AwWatcherNetBeans.documentListener = this; + } + + public void remove() { + this.document.removeDocumentListener(this); + } + + public void handleChange() { + final FileObject file = this.getFile(document); + if (file != null) { + final Project currentProject = this.getProject(file); + final OffsetDateTime currentTime = OffsetDateTime.now(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if ((!file.getPath().equals(AwWatcherNetBeans.lastFile) || AwWatcherNetBeans.enoughTimePassed(currentTime))) { + AwWatcherNetBeans.sendHeartbeat(currentTime, file, currentProject); + } + } + }); + } + } + + private FileObject getFile(Document document) { + if (document == null) { + return null; + } + Source source = Source.create(document); + if (source == null) { + return null; + } + FileObject fileObject = source.getFileObject(); + if (fileObject == null) { + return null; + } + return fileObject; + } + + private Project getProject(FileObject file) { + if (file == null) { + return null; + } + return FileOwnerQuery.getOwner(file); + } + +} diff --git a/src/com/github/pytlus93/AwWatcherNetBeans/EditorData.java b/src/com/github/pytlus93/AwWatcherNetBeans/EditorData.java new file mode 100644 index 0000000..fcf55db --- /dev/null +++ b/src/com/github/pytlus93/AwWatcherNetBeans/EditorData.java @@ -0,0 +1,16 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.github.pytlus93.AwWatcherNetBeans; + +/** + * + * @author FiVrCz + */ +public class EditorData { + public String language; + public String project; + public String file; +} diff --git a/src/com/github/pytlus93/AwWatcherNetBeans/exts.ini b/src/com/github/pytlus93/AwWatcherNetBeans/exts.ini new file mode 100644 index 0000000..9a23e6f --- /dev/null +++ b/src/com/github/pytlus93/AwWatcherNetBeans/exts.ini @@ -0,0 +1,900 @@ +1 = Groff +2 = Groff +3 = Groff +4 = Groff +5 = Groff +6 = Groff +7 = Groff +8 = Groff +9 = Groff +abap = ABAP +asc = Public Key +ash = AGS Script +ampl = AMPL +mod = XML +g4 = ANTLR +apib = API Blueprint +apl = APL +dyalog = APL +asp = ASP +asax = ASP +ascx = ASP +ashx = ASP +asmx = ASP +aspx = ASP +axd = ASP +dats = ATS +hats = ATS +sats = ATS +as = ActionScript +adb = Ada +ada = Ada +ads = Ada +agda = Agda +als = Alloy +apacheconf = ApacheConf +vhost = Nginx +cls = Visual Basic +applescript = AppleScript +scpt = AppleScript +arc = Arc +ino = Arduino +asciidoc = AsciiDoc +adoc = AsciiDoc +aj = AspectJ +asm = Assembly +a51 = Assembly +inc = SourcePawn +nasm = Assembly +aug = Augeas +ahk = AutoHotkey +ahkl = AutoHotkey +au3 = AutoIt +awk = Awk +auk = Awk +gawk = Awk +mawk = Awk +nawk = Awk +bat = Batchfile +cmd = Batchfile +befunge = Befunge +bison = Bison +bb = BlitzBasic +decls = BlitzBasic +bmx = BlitzMax +bsv = Bluespec +boo = Boo +b = Limbo +bf = HyPhy +brs = Brightscript +bro = Bro +c = C +cats = C +h = Objective-C +idc = C +w = C +cs = Smalltalk +cake = CoffeeScript +cshtml = C# +csx = C# +cpp = C++ +c++ = C++ +cc = C++ +cp = Component Pascal +cxx = C++ +h++ = C++ +hh = Hack +hpp = C++ +hxx = C++ +inl = C++ +ipp = C++ +tcc = C++ +tpp = C++ +c-objdump = C-ObjDump +chs = C2hs Haskell +clp = CLIPS +cmake = CMake +cmake.in = CMake +cob = COBOL +cbl = COBOL +ccp = COBOL +cobol = COBOL +cpy = COBOL +css = CSS +csv = CSV +capnp = Cap'n Proto +mss = CartoCSS +ceylon = Ceylon +chpl = Chapel +ch = xBase +ck = ChucK +cirru = Cirru +clw = Clarion +icl = Clean +dcl = Clean +click = Click +clj = Clojure +boot = Clojure +cl2 = Clojure +cljc = Clojure +cljs = Clojure +cljs.hl = Clojure +cljscm = Clojure +cljx = Clojure +hic = Clojure +coffee = CoffeeScript +_coffee = CoffeeScript +cjsx = CoffeeScript +cson = CoffeeScript +iced = CoffeeScript +cfm = ColdFusion +cfml = ColdFusion +cfc = ColdFusion CFC +lisp = NewLisp +asd = Common Lisp +cl = OpenCL +l = PicoLisp +lsp = NewLisp +ny = Common Lisp +podsl = Common Lisp +sexp = Common Lisp +cps = Component Pascal +coq = Coq +v = Verilog +cppobjdump = Cpp-ObjDump +c++-objdump = Cpp-ObjDump +c++objdump = Cpp-ObjDump +cpp-objdump = Cpp-ObjDump +cxx-objdump = Cpp-ObjDump +creole = Creole +cr = Crystal +feature = Cucumber +cu = Cuda +cuh = Cuda +cy = Cycript +pyx = Cython +pxd = Cython +pxi = Cython +d = Makefile +di = D +d-objdump = D-ObjDump +com = DIGITAL Command Language +dm = DM +zone = DNS Zone +arpa = DNS Zone +darcspatch = Darcs Patch +dpatch = Darcs Patch +dart = Dart +diff = Diff +patch = Diff +dockerfile = Dockerfile +djs = Dogescript +dylan = Dylan +dyl = Dylan +intr = Dylan +lid = Dylan +E = E +ecl = ECLiPSe +eclxml = ECL +sch = KiCad +brd = KiCad +epj = Ecere Projects +e = Eiffel +ex = Elixir +exs = Elixir +elm = Elm +el = Emacs Lisp +emacs = Emacs Lisp +emacs.desktop = Emacs Lisp +em = EmberScript +emberscript = EmberScript +erl = Erlang +es = JavaScript +escript = Erlang +hrl = Erlang +xrl = Erlang +yrl = Erlang +fs = GLSL +fsi = F# +fsx = F# +fx = HLSL +flux = FLUX +f90 = FORTRAN +f = Forth +f03 = FORTRAN +f08 = FORTRAN +f77 = FORTRAN +f95 = FORTRAN +for = Forth +fpp = FORTRAN +factor = Factor +fy = Fancy +fancypack = Fancy +fan = Fantom +eam.fs = Formatted +fth = Forth +4th = Forth +forth = Forth +fr = Text +frt = Forth +ftl = FreeMarker +g = GAP +gco = G-code +gcode = G-code +gms = GAMS +gap = GAP +gd = GDScript +gi = GAP +tst = Scilab +s = GAS +ms = MAXScript +glsl = GLSL +fp = GLSL +frag = JavaScript +frg = GLSL +fsh = GLSL +fshader = GLSL +geo = GLSL +geom = GLSL +glslv = GLSL +gshader = GLSL +shader = GLSL +vert = GLSL +vrx = GLSL +vsh = GLSL +vshader = GLSL +gml = XML +kid = Genshi +ebuild = Gentoo Ebuild +eclass = Gentoo Eclass +po = Gettext Catalog +pot = Gettext Catalog +glf = Glyph +gp = Gnuplot +gnu = Gnuplot +gnuplot = Gnuplot +plot = Gnuplot +plt = Gnuplot +go = Go +golo = Golo +gs = JavaScript +gst = Gosu +gsx = Gosu +vark = Gosu +grace = Grace +gradle = Gradle +gf = Grammatical Framework +graphql = GraphQL +dot = Graphviz (DOT) +gv = Graphviz (DOT) +man = Groff +1in = Groff +1m = Groff +1x = Groff +3in = Groff +3m = Groff +3qt = Groff +3x = Groff +me = Groff +n = Nemerle +rno = Groff +roff = Groff +groovy = Groovy +grt = Groovy +gtpl = Groovy +gvy = Groovy +gsp = Groovy Server Pages +hcl = HCL +tf = HCL +hlsl = HLSL +fxh = HLSL +hlsli = HLSL +html = HTML +htm = HTML +html.hl = HTML +st = Smalltalk +xht = HTML +xhtml = HTML +mustache = HTML+Django +jinja = HTML+Django +eex = HTML+EEX +erb = HTML+ERB +erb.deface = HTML+ERB +phtml = HTML+PHP +http = HTTP +php = PHP +haml = Haml +haml.deface = Haml +handlebars = Handlebars +hbs = Handlebars +hb = Harbour +hs = Haskell +hsc = Haskell +hx = Haxe +hxsl = Haxe +hy = Hy +pro = QMake +dlm = IDL +ipf = IGOR Pro +ini = INI +cfg = INI +prefs = INI +properties = INI +irclog = IRC log +weechatlog = IRC log +idr = Idris +lidr = Idris +ni = Inform 7 +i7x = Inform 7 +iss = Inno Setup +io = Io +ik = Ioke +thy = Isabelle +ijs = J +flex = JFlex +jflex = JFlex +json = JSON +geojson = JSON +lock = JSON +topojson = JSON +json5 = JSON5 +jsonld = JSONLD +jq = JSONiq +jsx = JSX +jade = Jade +j = Objective-J +java = Java +jsp = Java Server Pages +js = JavaScript +_js = JavaScript +bones = JavaScript +es6 = JavaScript +jake = JavaScript +jsb = JavaScript +jscad = JavaScript +jsfl = JavaScript +jsm = JavaScript +jss = JavaScript +njs = JavaScript +pac = JavaScript +sjs = JavaScript +ssjs = JavaScript +sublime-build = JavaScript +sublime-commands = JavaScript +sublime-completions = JavaScript +sublime-keymap = JavaScript +sublime-macro = JavaScript +sublime-menu = JavaScript +sublime-mousemap = JavaScript +sublime-project = JavaScript +sublime-settings = JavaScript +sublime-theme = JavaScript +sublime-workspace = JavaScript +sublime_metrics = JavaScript +sublime_session = JavaScript +xsjs = JavaScript +xsjslib = JavaScript +jl = Julia +ipynb = Jupyter Notebook +krl = KRL +kicad_pcb = KiCad +kit = Kit +kt = Kotlin +ktm = Kotlin +kts = Kotlin +lfe = LFE +ll = LLVM +lol = LOLCODE +lsl = LSL +lslp = LSL +lvproj = LabVIEW +lasso = Lasso +las = Lasso +lasso8 = Lasso +lasso9 = Lasso +ldml = Lasso +latte = Latte +lean = Lean +hlean = Lean +less = Less +lex = Lex +ly = LilyPond +ily = LilyPond +m = Objective-C +ld = Linker Script +lds = Linker Script +liquid = Liquid +lagda = Literate Agda +litcoffee = Literate CoffeeScript +lhs = Literate Haskell +ls = LoomScript +_ls = LiveScript +xm = Logos +x = Logos +xi = Logos +lgt = Logtalk +logtalk = Logtalk +lookml = LookML +lua = Lua +fcgi = Shell +nse = Lua +pd_lua = Lua +rbxs = Lua +wlua = Lua +mumps = M +m4 = M4Sugar +mcr = MAXScript +mtml = MTML +muf = MUF +mak = Makefile +mk = Makefile +mkfile = Makefile +mako = Mako +mao = Mako +md = Markdown +markdown = Markdown +mkd = Markdown +mkdn = Markdown +mkdown = Markdown +ron = Markdown +mask = Mask +mathematica = Mathematica +cdf = Mathematica +ma = Mathematica +mt = Mathematica +nb = Text +nbp = Mathematica +wl = Mathematica +wlt = Mathematica +matlab = Matlab +maxpat = Max +maxhelp = Max +maxproj = Max +mxt = Max +pat = Max +mediawiki = MediaWiki +wiki = MediaWiki +moo = Moocode +metal = Metal +minid = MiniD +druby = Mirah +duby = Mirah +mir = Mirah +mirah = Mirah +mo = Modelica +mms = Module Management System +mmk = Module Management System +monkey = Monkey +moon = MoonScript +myt = Myghty +ncl = Text +nl = NewLisp +nsi = NSIS +nsh = NSIS +axs = NetLinx +axi = NetLinx +axs.erb = NetLinx+ERB +axi.erb = NetLinx+ERB +nlogo = NetLogo +nginxconf = Nginx +nim = Nimrod +nimrod = Nimrod +ninja = Ninja +nit = Nit +nix = Nix +nu = Nu +numpy = NumPy +numpyw = NumPy +numsc = NumPy +ml = OCaml +eliom = OCaml +eliomi = OCaml +ml4 = OCaml +mli = OCaml +mll = OCaml +mly = OCaml +objdump = ObjDump +mm = XML +sj = Objective-J +omgrofl = Omgrofl +opa = Opa +opal = Opal +opencl = OpenCL +p = OpenEdge ABL +scad = OpenSCAD +org = Org +ox = Ox +oxh = Ox +oxo = Ox +oxygene = Oxygene +oz = Oz +pwn = PAWN +aw = PHP +ctp = PHP +php3 = PHP +php4 = PHP +php5 = PHP +phps = PHP +phpt = PHP +pls = PLSQL +pck = PLSQL +pkb = PLSQL +pks = PLSQL +plb = PLSQL +plsql = PLSQL +sql = SQLPL +pov = POV-Ray SDL +pan = Pan +psc = Papyrus +parrot = Parrot +pasm = Parrot Assembly +pir = Parrot Internal Representation +pas = Pascal +dfm = Pascal +dpr = Pascal +lpr = Pascal +pp = Puppet +pl = Prolog +al = Perl +cgi = Shell +perl = Perl +ph = Perl +plx = Perl +pm = Perl6 +pod = Pod +psgi = Perl +t = Turing +6pl = Perl6 +6pm = Perl6 +nqp = Perl6 +p6 = Perl6 +p6l = Perl6 +p6m = Perl6 +pl6 = Perl6 +pm6 = Perl6 +pkl = Pickle +pig = PigLatin +pike = Pike +pmod = Pike +pogo = PogoScript +pony = Pony +ps = PostScript +eps = PostScript +ps1 = PowerShell +psd1 = PowerShell +psm1 = PowerShell +pde = Processing +prolog = Prolog +yap = Prolog +spin = Propeller Spin +proto = Protocol Buffer +pub = Public Key +pd = Pure Data +pb = PureBasic +pbi = PureBasic +purs = PureScript +py = Python +bzl = Python +gyp = Python +lmi = Python +pyde = Python +pyp = Python +pyt = Python +pyw = Python +rpy = Ren'Py +tac = Python +wsgi = Python +xpy = Python +pytb = Python traceback +qml = QML +qbs = QML +pri = QMake +r = Rebol +rd = R +rsx = R +raml = RAML +rdoc = RDoc +rbbas = REALbasic +rbfrm = REALbasic +rbmnu = REALbasic +rbres = REALbasic +rbtbar = REALbasic +rbuistate = REALbasic +rhtml = RHTML +rmd = RMarkdown +rkt = Racket +rktd = Racket +rktl = Racket +scrbl = Racket +rl = Ragel in Ruby Host +raw = Raw token data +reb = Rebol +r2 = Rebol +r3 = Rebol +rebol = Rebol +red = Red +reds = Red +cw = Redcode +rs = Rust +rsh = RenderScript +robot = RobotFramework +rg = Rouge +rb = Ruby +builder = Ruby +gemspec = Ruby +god = Ruby +irbrc = Ruby +jbuilder = Ruby +mspec = Ruby +pluginspec = XML +podspec = Ruby +rabl = Ruby +rake = Ruby +rbuild = Ruby +rbw = Ruby +rbx = Ruby +ru = Ruby +ruby = Ruby +thor = Ruby +watchr = Ruby +rs.in = Rust +sas = SAS +scss = SCSS +smt2 = SMT +smt = SMT +sparql = SPARQL +rq = SPARQL +sqf = SQF +hqf = SQF +cql = SQL +ddl = SQL +prc = SQL +tab = SQL +udf = SQL +viw = SQL +db2 = SQLPL +ston = STON +svg = SVG +sage = Sage +sagews = Sage +sls = Scheme +sass = Sass +scala = Scala +sbt = Scala +sc = SuperCollider +scaml = Scaml +scm = Scheme +sld = Scheme +sps = Scheme +ss = Scheme +sci = Scilab +sce = Scilab +self = Self +sh = Shell +bash = Shell +bats = Shell +command = Shell +ksh = Shell +sh.in = Shell +tmux = Shell +tool = Shell +zsh = Shell +sh-session = ShellSession +shen = Shen +sl = Slash +slim = Slim +smali = Smali +tpl = Smarty +sp = SourcePawn +sma = SourcePawn +nut = Squirrel +stan = Stan +ML = Standard ML +fun = Standard ML +sig = Standard ML +sml = Standard ML +do = Stata +ado = Stata +doh = Stata +ihlp = Stata +mata = Stata +matah = Stata +sthlp = Stata +styl = Stylus +scd = SuperCollider +swift = Swift +sv = SystemVerilog +svh = SystemVerilog +vh = SystemVerilog +toml = TOML +txl = TXL +tcl = Tcl +adp = Tcl +tm = Tcl +tcsh = Tcsh +csh = Tcsh +tex = TeX +aux = TeX +bbx = TeX +bib = TeX +cbx = TeX +dtx = TeX +ins = TeX +lbx = TeX +ltx = TeX +mkii = TeX +mkiv = TeX +mkvi = TeX +sty = TeX +toc = TeX +tea = Tea +txt = Text +no = Text +textile = Textile +thrift = Thrift +tu = Turing +ttl = Turtle +twig = Twig +ts = XML +tsx = XML +upc = Unified Parallel C +anim = Unity3D Asset +asset = Unity3D Asset +mat = Unity3D Asset +meta = Unity3D Asset +prefab = Unity3D Asset +unity = Unity3D Asset +uno = Uno +uc = UnrealScript +ur = UrWeb +urs = UrWeb +vcl = VCL +vhdl = VHDL +vhd = VHDL +vhf = VHDL +vhi = VHDL +vho = VHDL +vhs = VHDL +vht = VHDL +vhw = VHDL +vala = Vala +vapi = Vala +veo = Verilog +vim = VimL +vb = Visual Basic +bas = Visual Basic +frm = Visual Basic +frx = Visual Basic +vba = Visual Basic +vbhtml = Visual Basic +vbs = Visual Basic +volt = Volt +vue = Vue +owl = Web Ontology Language +webidl = WebIDL +x10 = X10 +xc = XC +xml = XML +ant = XML +axml = XML +ccxml = XML +clixml = XML +cproject = XML +csl = XML +csproj = XML +ct = XML +dita = XML +ditamap = XML +ditaval = XML +dll.config = XML +dotsettings = XML +filters = XML +fsproj = XML +fxml = XML +glade = XML +grxml = XML +iml = XML +ivy = XML +jelly = XML +jsproj = XML +kml = XML +launch = XML +mdpolicy = XML +mxml = XML +nproj = XML +nuspec = XML +odd = XML +osm = XML +plist = XML +props = XML +ps1xml = XML +psc1 = XML +pt = XML +rdf = XML +rss = XML +scxml = XML +srdf = XML +storyboard = XML +stTheme = XML +sublime-snippet = XML +targets = XML +tmCommand = XML +tml = XML +tmLanguage = XML +tmPreferences = XML +tmSnippet = XML +tmTheme = XML +ui = XML +urdf = XML +ux = XML +vbproj = XML +vcxproj = XML +vssettings = XML +vxml = XML +wsdl = XML +wsf = XML +wxi = XML +wxl = XML +wxs = XML +x3d = XML +xacro = XML +xaml = XML +xib = XML +xlf = XML +xliff = XML +xmi = XML +xml.dist = XML +xproj = XML +xsd = XML +xul = XML +zcml = XML +xsp-config = XPages +xsp.metadata = XPages +xpl = XProc +xproc = XProc +xquery = XQuery +xq = XQuery +xql = XQuery +xqm = XQuery +xqy = XQuery +xs = XS +xslt = XSLT +xsl = XSLT +xojo_code = Xojo +xojo_menu = Xojo +xojo_report = Xojo +xojo_script = Xojo +xojo_toolbar = Xojo +xojo_window = Xojo +xtend = Xtend +yml = YAML +reek = YAML +rviz = YAML +sublime-syntax = YAML +syntax = YAML +yaml = YAML +yaml-tmlanguage = YAML +yang = YANG +y = Yacc +yacc = Yacc +yy = Yacc +zep = Zephir +zimpl = Zimpl +zmpl = Zimpl +zpl = Zimpl +desktop = desktop +desktop.in = desktop +ec = eC +eh = eC +edn = edn +fish = fish +mu = mupad +nc = nesC +ooc = ooc +rst = reStructuredText +rest = reStructuredText +rest.txt = reStructuredText +rst.txt = reStructuredText +wisp = wisp +prg = xBase +prw = xBase \ No newline at end of file diff --git a/src/com/github/pytlus93/AwWatcherNetBeans/logo_32.png b/src/com/github/pytlus93/AwWatcherNetBeans/logo_32.png new file mode 100644 index 0000000..f4ffcc9 Binary files /dev/null and b/src/com/github/pytlus93/AwWatcherNetBeans/logo_32.png differ diff --git a/src/io/swagger/client/ApiCallback.java b/src/io/swagger/client/ApiCallback.java new file mode 100644 index 0000000..45543bc --- /dev/null +++ b/src/io/swagger/client/ApiCallback.java @@ -0,0 +1,62 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import java.io.IOException; + +import java.util.Map; +import java.util.List; + +/** + * Callback for asynchronous API call. + * + * @param The return type + */ +public interface ApiCallback { + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure(ApiException e, int statusCode, Map> responseHeaders); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map> responseHeaders); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API downlond processing. + * + * @param bytesRead bytes Read + * @param contentLength content lenngth of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} diff --git a/src/io/swagger/client/ApiClient.java b/src/io/swagger/client/ApiClient.java new file mode 100644 index 0000000..6efa5ea --- /dev/null +++ b/src/io/swagger/client/ApiClient.java @@ -0,0 +1,1207 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import com.squareup.okhttp.*; +import com.squareup.okhttp.internal.http.HttpMethod; +import com.squareup.okhttp.logging.HttpLoggingInterceptor; +import com.squareup.okhttp.logging.HttpLoggingInterceptor.Level; +import okio.BufferedSink; +import okio.Okio; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.format.DateTimeFormatter; + +import javax.net.ssl.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.lang.reflect.Type; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.text.DateFormat; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import io.swagger.client.auth.Authentication; +import io.swagger.client.auth.HttpBasicAuth; +import io.swagger.client.auth.ApiKeyAuth; +import io.swagger.client.auth.OAuth; + +public class ApiClient { + + private String basePath = "https://localhost/api"; + private boolean debugging = false; + private Map defaultHeaderMap = new HashMap(); + private String tempFolderPath = null; + + private Map authentications; + + private DateFormat dateFormat; + private DateFormat datetimeFormat; + private boolean lenientDatetimeFormat; + private int dateLength; + + private InputStream sslCaCert; + private boolean verifyingSsl; + private KeyManager[] keyManagers; + + private OkHttpClient httpClient; + private JSON json; + + private HttpLoggingInterceptor loggingInterceptor; + + /* + * Constructor for ApiClient + */ + public ApiClient() { + httpClient = new OkHttpClient(); + + + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent("Swagger-Codegen/1.0.0/java"); + + // Setup authentications (key: authentication name, value: authentication). + authentications = new HashMap(); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + /** + * Get base path + * + * @return Baes path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g https://localhost/api + * @return An instance of OkHttpClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + /** + * Get HTTP client + * + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Set HTTP client + * + * @param httpClient An instance of OkHttpClient + * @return Api Client + */ + public ApiClient setHttpClient(OkHttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. + * Default to true. + * NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks. + * + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. + * Use null to reset to default. + * + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + public KeyManager[] getKeyManagers() { + return keyManagers; + } + + /** + * Configure client keys to use for authorization in an SSL session. + * Use null to reset to default. + * + * @param managers The KeyManagers to use + * @return ApiClient + */ + public ApiClient setKeyManagers(KeyManager[] managers) { + this.keyManagers = managers; + applySslSettings(); + return this; + } + + public DateFormat getDateFormat() { + return dateFormat; + } + + public ApiClient setDateFormat(DateFormat dateFormat) { + this.json.setDateFormat(dateFormat); + return this; + } + + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + this.json.setSqlDateFormat(dateFormat); + return this; + } + + public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + this.json.setOffsetDateTimeFormat(dateFormat); + return this; + } + + public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { + this.json.setLocalDateFormat(dateFormat); + return this; + } + + public ApiClient setLenientOnJson(boolean lenientOnJson) { + this.json.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map of authentication objects + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + /** + * Helper method to set username for the first HTTP basic authentication. + * + * @param username Username + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + * + * @param password Password + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + * + * @param apiKey API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + * + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set access token for the first OAuth2 authentication. + * + * @param accessToken Access token + */ + public void setAccessToken(String accessToken) { + for (Authentication auth : authentications.values()) { + if (auth instanceof OAuth) { + ((OAuth) auth).setAccessToken(accessToken); + return; + } + } + throw new RuntimeException("No OAuth2 authentication configured!"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient.interceptors().add(loggingInterceptor); + } else { + httpClient.interceptors().remove(loggingInterceptor); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * The path of temporary folder used to store downloaded files from endpoints + * with file response. The default value is null, i.e. using + * the system's default tempopary folder. + * + * @see createTempFile + * @return Temporary folder path + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + /** + * Set the temporary folder path (for downloading files) + * + * @param tempFolderPath Temporary folder path + * @return ApiClient + */ + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getConnectTimeout() { + return httpClient.getConnectTimeout(); + } + + /** + * Sets the connect timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * + * @param connectionTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setConnectTimeout(int connectionTimeout) { + httpClient.setConnectTimeout(connectionTimeout, TimeUnit.MILLISECONDS); + return this; + } + + /** + * Get read timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getReadTimeout() { + return httpClient.getReadTimeout(); + } + + /** + * Sets the read timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * + * @param readTimeout read timeout in milliseconds + * @return Api client + */ + public ApiClient setReadTimeout(int readTimeout) { + httpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS); + return this; + } + + /** + * Get write timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getWriteTimeout() { + return httpClient.getWriteTimeout(); + } + + /** + * Sets the write timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * + * @param writeTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setWriteTimeout(int writeTimeout) { + httpClient.setWriteTimeout(writeTimeout, TimeUnit.MILLISECONDS); + return this; + } + + /** + * Format the given parameter object into string. + * + * @param param Parameter + * @return String representation of the parameter + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { + //Serialize to json string and remove the " enclosing characters + String jsonStr = json.serialize(param); + return jsonStr.substring(1, jsonStr.length() - 1); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection)param) { + if (b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * + * Note that {@code value} must not be a collection. + * + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List parameterToPair(String name, Object value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value instanceof Collection) return params; + + params.add(new Pair(name, parameterToString(value))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} objects. + * + * Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceAll(".*[/\\\\]", ""); + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * "* / *" is also default to JSON + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: + * if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, + * null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: + * if JSON exists in the given array, use it; + * otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, + * or matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0 || contentTypes[0].equals("*/*")) { + return "application/json"; + } + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and + * the Content-Type response header. + * + * @param Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws ApiException If fail to deserialize response body, i.e. cannot read response body + * or the Content-Type of the response is not supported. + */ + @SuppressWarnings("unchecked") + public T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } catch (IOException e) { + throw new ApiException(e); + } + } else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + String respBody; + try { + if (response.body() != null) + respBody = response.body().string(); + else + respBody = null; + } catch (IOException e) { + throw new ApiException(e); + } + + if (respBody == null || "".equals(respBody)) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + if (isJsonMime(contentType)) { + return json.deserialize(respBody, returnType); + } else if (returnType.equals(String.class)) { + // Expecting string, return the raw response body. + return (T) respBody; + } else { + throw new ApiException( + "Content type \"" + contentType + "\" is not supported for type: " + returnType, + response.code(), + response.headers().toMultimap(), + respBody); + } + } + + /** + * Serialize the given Java object into request body according to the object's + * class and the request Content-Type. + * + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws ApiException If fail to serialize the given object + */ + public RequestBody serialize(Object obj, String contentType) throws ApiException { + if (obj instanceof byte[]) { + // Binary (byte array) body parameter support. + return RequestBody.create(MediaType.parse(contentType), (byte[]) obj); + } else if (obj instanceof File) { + // File body parameter support. + return RequestBody.create(MediaType.parse(contentType), (File) obj); + } else if (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = json.serialize(obj); + } else { + content = null; + } + return RequestBody.create(MediaType.parse(contentType), content); + } else { + throw new ApiException("Content type \"" + contentType + "\" is not supported"); + } + } + + /** + * Download file from the given response. + * + * @param response An instance of the Response object + * @throws ApiException If fail to read file content from response and write to disk + * @return Downloaded file + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + BufferedSink sink = Okio.buffer(Okio.sink(file)); + sink.writeAll(response.body().source()); + sink.close(); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare file for download + * + * @param response An instance of the Response object + * @throws IOException If fail to prepare file for download + * @return Prepared file for the download + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = response.header("Content-Disposition"); + if (contentDisposition != null && !"".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = sanitizeFilename(matcher.group(1)); + } + } + + String prefix = null; + String suffix = null; + if (filename == null) { + prefix = "download-"; + suffix = ""; + } else { + int pos = filename.lastIndexOf("."); + if (pos == -1) { + prefix = filename + "-"; + } else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // File.createTempFile requires the prefix to be at least three characters long + if (prefix.length() < 3) + prefix = "download-"; + } + + if (tempFolderPath == null) + return Files.createTempFile(prefix, suffix).toFile(); + else + return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); + } + + /** + * {@link #execute(Call, Type)} + * + * @param Type + * @param call An instance of the Call object + * @throws ApiException If fail to execute the call + * @return ApiResponse<T> + */ + public ApiResponse execute(Call call) throws ApiException { + return execute(call, null); + } + + /** + * Execute HTTP call and deserialize the HTTP response body into the given return type. + * + * @param returnType The return type used to deserialize HTTP response body + * @param The return type corresponding to (same with) returnType + * @param call Call + * @return ApiResponse object containing response status, headers and + * data, which is a Java object deserialized from response body and would be null + * when returnType is null. + * @throws ApiException If fail to execute the call + */ + public ApiResponse execute(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * {@link #executeAsync(Call, Type, ApiCallback)} + * + * @param Type + * @param call An instance of the Call object + * @param callback ApiCallback<T> + */ + public void executeAsync(Call call, ApiCallback callback) { + executeAsync(call, null, callback); + } + + /** + * Execute HTTP call asynchronously. + * + * @see #execute(Call, Type) + * @param Type + * @param call The callback to be executed when the API call finishes + * @param returnType Return type + * @param callback ApiCallback + */ + @SuppressWarnings("unchecked") + public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { + call.enqueue(new Callback() { + @Override + public void onFailure(Request request, IOException e) { + callback.onFailure(new ApiException(e), 0, null); + } + + @Override + public void onResponse(Response response) throws IOException { + T result; + try { + result = (T) handleResponse(response, returnType); + } catch (ApiException e) { + callback.onFailure(e, response.code(), response.headers().toMultimap()); + return; + } + callback.onSuccess(result, response.code(), response.headers().toMultimap()); + } + }); + } + + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @param Type + * @param response Response + * @param returnType Return type + * @throws ApiException If the response has a unsuccessful status code or + * fail to deserialize the response body + * @return Type + */ + public T handleResponse(Response response, Type returnType) throws ApiException { + if (response.isSuccessful()) { + if (returnType == null || response.code() == 204) { + // returning null if the returnType is not defined, + // or the status code is 204 (No Content) + if (response.body() != null) { + try { + response.body().close(); + } catch (IOException e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + return null; + } else { + return deserialize(response, returnType); + } + } else { + String respBody = null; + if (response.body() != null) { + try { + respBody = response.body().string(); + } catch (IOException e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Build HTTP call with the given options. + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param progressRequestListener Progress request listener + * @return The HTTP call + * @throws ApiException If fail to serialize the request body object + */ + public Call buildCall(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, progressRequestListener); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param progressRequestListener Progress request listener + * @return The HTTP request + * @throws ApiException If fail to serialize the request body object + */ + public Request buildRequest(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + updateParamsForAuth(authNames, queryParams, headerParams); + + final String url = buildUrl(path, queryParams, collectionQueryParams); + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + + String contentType = headerParams.get("Content-Type"); + // ensuring a default content type + if (contentType == null) { + contentType = "application/json"; + } + + RequestBody reqBody; + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if ("application/x-www-form-urlencoded".equals(contentType)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if ("multipart/form-data".equals(contentType)) { + reqBody = buildRequestBodyMultipart(formParams); + } else if (body == null) { + if ("DELETE".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = RequestBody.create(MediaType.parse(contentType), ""); + } + } else { + reqBody = serialize(body, contentType); + } + + Request request = null; + + if(progressRequestListener != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl(String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + url.append(basePath).append(path); + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())).append("=").append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the ofrm of Map + * @param reqBuilder Reqeust.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + */ + public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams) { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); + auth.applyToParams(queryParams, headerParams); + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + FormEncodingBuilder formBuilder = new FormEncodingBuilder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, + * which could contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBuilder mpBuilder = new MultipartBuilder().type(MultipartBuilder.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(mediaType, file)); + } else { + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\""); + mpBuilder.addPart(partHeaders, RequestBody.create(null, parameterToString(param.getValue()))); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to "application/octet-stream"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } else { + return contentType; + } + } + + /** + * Apply SSL related settings to httpClient according to the current values of + * verifyingSsl and sslCaCert. + */ + private void applySslSettings() { + try { + TrustManager[] trustManagers = null; + HostnameVerifier hostnameVerifier = null; + if (!verifyingSsl) { + TrustManager trustAll = new X509TrustManager() { + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {} + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {} + @Override + public X509Certificate[] getAcceptedIssuers() { return null; } + }; + SSLContext sslContext = SSLContext.getInstance("TLS"); + trustManagers = new TrustManager[]{ trustAll }; + hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { return true; } + }; + } else if (sslCaCert != null) { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + Collection certificates = certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException("expected non-empty set of trusted certificates"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = "ca" + Integer.toString(index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + trustManagerFactory.init(caKeyStore); + trustManagers = trustManagerFactory.getTrustManagers(); + } + + if (keyManagers != null || trustManagers != null) { + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient.setSslSocketFactory(sslContext.getSocketFactory()); + } else { + httpClient.setSslSocketFactory(null); + } + httpClient.setHostnameVerifier(hostnameVerifier); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } catch (IOException e) { + throw new AssertionError(e); + } + } +} diff --git a/src/io/swagger/client/ApiException.java b/src/io/swagger/client/ApiException.java new file mode 100644 index 0000000..2824d41 --- /dev/null +++ b/src/io/swagger/client/ApiException.java @@ -0,0 +1,91 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class ApiException extends Exception { + private int code = 0; + private Map> responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public ApiException(String message, int code, Map> responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException(int code, Map> responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } +} diff --git a/src/io/swagger/client/ApiResponse.java b/src/io/swagger/client/ApiResponse.java new file mode 100644 index 0000000..b94c6a5 --- /dev/null +++ b/src/io/swagger/client/ApiResponse.java @@ -0,0 +1,59 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/src/io/swagger/client/Configuration.java b/src/io/swagger/client/Configuration.java new file mode 100644 index 0000000..83d4355 --- /dev/null +++ b/src/io/swagger/client/Configuration.java @@ -0,0 +1,39 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class Configuration { + private static ApiClient defaultApiClient = new ApiClient(); + + /** + * Get the default API client, which would be used when creating API + * instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + + /** + * Set the default API client, which would be used when creating API + * instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } +} diff --git a/src/io/swagger/client/GzipRequestInterceptor.java b/src/io/swagger/client/GzipRequestInterceptor.java new file mode 100644 index 0000000..e5e00bf --- /dev/null +++ b/src/io/swagger/client/GzipRequestInterceptor.java @@ -0,0 +1,81 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import com.squareup.okhttp.*; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +import java.io.IOException; + +/** + * Encodes request bodies using gzip. + * + * Taken from https://github.com/square/okhttp/issues/350 + */ +class GzipRequestInterceptor implements Interceptor { + @Override public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = originalRequest.newBuilder() + .header("Content-Encoding", "gzip") + .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) + .build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() { + return buffer.size(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } + + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override public MediaType contentType() { + return body.contentType(); + } + + @Override public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } +} \ No newline at end of file diff --git a/src/io/swagger/client/JSON.java b/src/io/swagger/client/JSON.java new file mode 100644 index 0000000..b48e406 --- /dev/null +++ b/src/io/swagger/client/JSON.java @@ -0,0 +1,394 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonElement; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.format.DateTimeFormatter; + +import io.swagger.client.model.*; +import okio.ByteString; + +import java.io.IOException; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.util.Date; +import java.util.Map; +import java.util.HashMap; + +public class JSON { + private Gson gson; + private boolean isLenientOnJson = false; + private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + ; + GsonBuilder builder = fireBuilder.createGsonBuilder(); + return builder; + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if(null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + +// private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { +// Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase()); +// if(null == clazz) { +// throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); +// } +// return clazz; +// } + + public JSON() { + gson = createGson() + .registerTypeAdapter(Date.class, dateTypeAdapter) + .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) + .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) + .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) + .registerTypeAdapter(byte[].class, byteArrayAdapter) + .create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + * @return JSON + */ + public JSON setGson(Gson gson) { + this.gson = gson; + return this; + } + + public JSON setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + return this; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public T deserialize(String body, Type returnType) { + try { + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } + } catch (JsonParseException e) { + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) + return (T) body; + else throw (e); + } + } + + /** + * Gson TypeAdapter for Byte Array type + */ + public class ByteArrayAdapter extends TypeAdapter { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + } + + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length()-5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + return this; + } + + /** + * Gson TypeAdapter for java.sql.Date type + * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used + * (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() { + } + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type + * If the dateFormat is null, ISO8601Utils will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() { + } + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } + + public JSON setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + return this; + } + +} diff --git a/src/io/swagger/client/Pair.java b/src/io/swagger/client/Pair.java new file mode 100644 index 0000000..aa92d39 --- /dev/null +++ b/src/io/swagger/client/Pair.java @@ -0,0 +1,52 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class Pair { + private String name = ""; + private String value = ""; + + public Pair (String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) return; + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) return; + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) return false; + if (arg.trim().isEmpty()) return false; + + return true; + } +} diff --git a/src/io/swagger/client/ProgressRequestBody.java b/src/io/swagger/client/ProgressRequestBody.java new file mode 100644 index 0000000..ddb94b9 --- /dev/null +++ b/src/io/swagger/client/ProgressRequestBody.java @@ -0,0 +1,77 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import com.squareup.okhttp.MediaType; +import com.squareup.okhttp.RequestBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSink; +import okio.ForwardingSink; +import okio.Okio; +import okio.Sink; + +public class ProgressRequestBody extends RequestBody { + + public interface ProgressRequestListener { + void onRequestProgress(long bytesWritten, long contentLength, boolean done); + } + + private final RequestBody requestBody; + + private final ProgressRequestListener progressListener; + + public ProgressRequestBody(RequestBody requestBody, ProgressRequestListener progressListener) { + this.requestBody = requestBody; + this.progressListener = progressListener; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + + long bytesWritten = 0L; + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + progressListener.onRequestProgress(bytesWritten, contentLength, bytesWritten == contentLength); + } + }; + } +} diff --git a/src/io/swagger/client/ProgressResponseBody.java b/src/io/swagger/client/ProgressResponseBody.java new file mode 100644 index 0000000..738a2b3 --- /dev/null +++ b/src/io/swagger/client/ProgressResponseBody.java @@ -0,0 +1,76 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +import com.squareup.okhttp.MediaType; +import com.squareup.okhttp.ResponseBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; +import okio.Source; + +public class ProgressResponseBody extends ResponseBody { + + public interface ProgressListener { + void update(long bytesRead, long contentLength, boolean done); + } + + private final ResponseBody responseBody; + private final ProgressListener progressListener; + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ProgressListener progressListener) { + this.responseBody = responseBody; + this.progressListener = progressListener; + } + + @Override + public MediaType contentType() { + return responseBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return responseBody.contentLength(); + } + + @Override + public BufferedSource source() throws IOException { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } + + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; + + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + progressListener.update(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + return bytesRead; + } + }; + } +} + + diff --git a/src/io/swagger/client/StringUtil.java b/src/io/swagger/client/StringUtil.java new file mode 100644 index 0000000..c71e533 --- /dev/null +++ b/src/io/swagger/client/StringUtil.java @@ -0,0 +1,55 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client; + +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) return true; + if (value != null && value.equalsIgnoreCase(str)) return true; + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) return ""; + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } +} diff --git a/src/io/swagger/client/api/DefaultApi.java b/src/io/swagger/client/api/DefaultApi.java new file mode 100644 index 0000000..6277aad --- /dev/null +++ b/src/io/swagger/client/api/DefaultApi.java @@ -0,0 +1,1920 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.api; + +import io.swagger.client.ApiCallback; +import io.swagger.client.ApiClient; +import io.swagger.client.ApiException; +import io.swagger.client.ApiResponse; +import io.swagger.client.Configuration; +import io.swagger.client.Pair; +import io.swagger.client.ProgressRequestBody; +import io.swagger.client.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import io.swagger.client.model.Bucket; +import io.swagger.client.model.CreateBucket; +import io.swagger.client.model.Event; +import io.swagger.client.model.Export; +import io.swagger.client.model.Info; +import io.swagger.client.model.Query; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultApi { + private ApiClient apiClient; + + public DefaultApi() { + this(Configuration.getDefaultApiClient()); + } + + public DefaultApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * Build call for deleteBucketResource + * @param bucketId (required) + * @param force Needs to be =1 to delete a bucket it non-testing mode (optional) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call deleteBucketResourceCall(String bucketId, String force, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/0/buckets/{bucket_id}" + .replaceAll("\\{" + "bucket_id" + "\\}", apiClient.escapeString(bucketId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + if (force != null) + localVarQueryParams.addAll(apiClient.parameterToPair("force", force)); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call deleteBucketResourceValidateBeforeCall(String bucketId, String force, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'bucketId' is set + if (bucketId == null) { + throw new ApiException("Missing the required parameter 'bucketId' when calling deleteBucketResource(Async)"); + } + + + com.squareup.okhttp.Call call = deleteBucketResourceCall(bucketId, force, progressListener, progressRequestListener); + return call; + + } + + /** + * Delete a bucket + * + * @param bucketId (required) + * @param force Needs to be =1 to delete a bucket it non-testing mode (optional) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void deleteBucketResource(String bucketId, String force) throws ApiException { + deleteBucketResourceWithHttpInfo(bucketId, force); + } + + /** + * Delete a bucket + * + * @param bucketId (required) + * @param force Needs to be =1 to delete a bucket it non-testing mode (optional) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse deleteBucketResourceWithHttpInfo(String bucketId, String force) throws ApiException { + com.squareup.okhttp.Call call = deleteBucketResourceValidateBeforeCall(bucketId, force, null, null); + return apiClient.execute(call); + } + + /** + * Delete a bucket (asynchronously) + * + * @param bucketId (required) + * @param force Needs to be =1 to delete a bucket it non-testing mode (optional) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call deleteBucketResourceAsync(String bucketId, String force, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = deleteBucketResourceValidateBeforeCall(bucketId, force, progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } + /** + * Build call for deleteEventResource + * @param bucketId (required) + * @param eventId (required) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call deleteEventResourceCall(String bucketId, String eventId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/0/buckets/{bucket_id}/events/{event_id}" + .replaceAll("\\{" + "bucket_id" + "\\}", apiClient.escapeString(bucketId.toString())) + .replaceAll("\\{" + "event_id" + "\\}", apiClient.escapeString(eventId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call deleteEventResourceValidateBeforeCall(String bucketId, String eventId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'bucketId' is set + if (bucketId == null) { + throw new ApiException("Missing the required parameter 'bucketId' when calling deleteEventResource(Async)"); + } + + // verify the required parameter 'eventId' is set + if (eventId == null) { + throw new ApiException("Missing the required parameter 'eventId' when calling deleteEventResource(Async)"); + } + + + com.squareup.okhttp.Call call = deleteEventResourceCall(bucketId, eventId, progressListener, progressRequestListener); + return call; + + } + + /** + * Delete a single event from a bucket + * + * @param bucketId (required) + * @param eventId (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void deleteEventResource(String bucketId, String eventId) throws ApiException { + deleteEventResourceWithHttpInfo(bucketId, eventId); + } + + /** + * Delete a single event from a bucket + * + * @param bucketId (required) + * @param eventId (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse deleteEventResourceWithHttpInfo(String bucketId, String eventId) throws ApiException { + com.squareup.okhttp.Call call = deleteEventResourceValidateBeforeCall(bucketId, eventId, null, null); + return apiClient.execute(call); + } + + /** + * Delete a single event from a bucket (asynchronously) + * + * @param bucketId (required) + * @param eventId (required) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call deleteEventResourceAsync(String bucketId, String eventId, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = deleteEventResourceValidateBeforeCall(bucketId, eventId, progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } + /** + * Build call for getBucketExportResource + * @param bucketId (required) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call getBucketExportResourceCall(String bucketId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/0/buckets/{bucket_id}/export" + .replaceAll("\\{" + "bucket_id" + "\\}", apiClient.escapeString(bucketId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call getBucketExportResourceValidateBeforeCall(String bucketId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'bucketId' is set + if (bucketId == null) { + throw new ApiException("Missing the required parameter 'bucketId' when calling getBucketExportResource(Async)"); + } + + + com.squareup.okhttp.Call call = getBucketExportResourceCall(bucketId, progressListener, progressRequestListener); + return call; + + } + + /** + * Export a bucket to a dataformat consistent across versions, including all events in it + * + * @param bucketId (required) + * @return Export + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public Export getBucketExportResource(String bucketId) throws ApiException { + ApiResponse resp = getBucketExportResourceWithHttpInfo(bucketId); + return resp.getData(); + } + + /** + * Export a bucket to a dataformat consistent across versions, including all events in it + * + * @param bucketId (required) + * @return ApiResponse<Export> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getBucketExportResourceWithHttpInfo(String bucketId) throws ApiException { + com.squareup.okhttp.Call call = getBucketExportResourceValidateBeforeCall(bucketId, null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Export a bucket to a dataformat consistent across versions, including all events in it (asynchronously) + * + * @param bucketId (required) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call getBucketExportResourceAsync(String bucketId, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = getBucketExportResourceValidateBeforeCall(bucketId, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } + /** + * Build call for getBucketResource + * @param bucketId (required) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call getBucketResourceCall(String bucketId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/0/buckets/{bucket_id}" + .replaceAll("\\{" + "bucket_id" + "\\}", apiClient.escapeString(bucketId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call getBucketResourceValidateBeforeCall(String bucketId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'bucketId' is set + if (bucketId == null) { + throw new ApiException("Missing the required parameter 'bucketId' when calling getBucketResource(Async)"); + } + + + com.squareup.okhttp.Call call = getBucketResourceCall(bucketId, progressListener, progressRequestListener); + return call; + + } + + /** + * Get metadata about bucket + * + * @param bucketId (required) + * @return Bucket + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public Bucket getBucketResource(String bucketId) throws ApiException { + ApiResponse resp = getBucketResourceWithHttpInfo(bucketId); + return resp.getData(); + } + + /** + * Get metadata about bucket + * + * @param bucketId (required) + * @return ApiResponse<Bucket> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getBucketResourceWithHttpInfo(String bucketId) throws ApiException { + com.squareup.okhttp.Call call = getBucketResourceValidateBeforeCall(bucketId, null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Get metadata about bucket (asynchronously) + * + * @param bucketId (required) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call getBucketResourceAsync(String bucketId, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = getBucketResourceValidateBeforeCall(bucketId, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } + /** + * Build call for getBucketsResource + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call getBucketsResourceCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/0/buckets/"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call getBucketsResourceValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + + com.squareup.okhttp.Call call = getBucketsResourceCall(progressListener, progressRequestListener); + return call; + + } + + /** + * Get dict {bucket_name: Bucket} of all buckets + * + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void getBucketsResource() throws ApiException { + getBucketsResourceWithHttpInfo(); + } + + /** + * Get dict {bucket_name: Bucket} of all buckets + * + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getBucketsResourceWithHttpInfo() throws ApiException { + com.squareup.okhttp.Call call = getBucketsResourceValidateBeforeCall(null, null); + return apiClient.execute(call); + } + + /** + * Get dict {bucket_name: Bucket} of all buckets (asynchronously) + * + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call getBucketsResourceAsync(final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = getBucketsResourceValidateBeforeCall(progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } + /** + * Build call for getEventCountResource + * @param bucketId (required) + * @param end End date of eventcount (optional) + * @param start Start date of eventcount (optional) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call getEventCountResourceCall(String bucketId, String end, String start, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/0/buckets/{bucket_id}/events/count" + .replaceAll("\\{" + "bucket_id" + "\\}", apiClient.escapeString(bucketId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + if (end != null) + localVarQueryParams.addAll(apiClient.parameterToPair("end", end)); + if (start != null) + localVarQueryParams.addAll(apiClient.parameterToPair("start", start)); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call getEventCountResourceValidateBeforeCall(String bucketId, String end, String start, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'bucketId' is set + if (bucketId == null) { + throw new ApiException("Missing the required parameter 'bucketId' when calling getEventCountResource(Async)"); + } + + + com.squareup.okhttp.Call call = getEventCountResourceCall(bucketId, end, start, progressListener, progressRequestListener); + return call; + + } + + /** + * Get eventcount from a bucket + * + * @param bucketId (required) + * @param end End date of eventcount (optional) + * @param start Start date of eventcount (optional) + * @return Integer + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public Integer getEventCountResource(String bucketId, String end, String start) throws ApiException { + ApiResponse resp = getEventCountResourceWithHttpInfo(bucketId, end, start); + return resp.getData(); + } + + /** + * Get eventcount from a bucket + * + * @param bucketId (required) + * @param end End date of eventcount (optional) + * @param start Start date of eventcount (optional) + * @return ApiResponse<Integer> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getEventCountResourceWithHttpInfo(String bucketId, String end, String start) throws ApiException { + com.squareup.okhttp.Call call = getEventCountResourceValidateBeforeCall(bucketId, end, start, null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Get eventcount from a bucket (asynchronously) + * + * @param bucketId (required) + * @param end End date of eventcount (optional) + * @param start Start date of eventcount (optional) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call getEventCountResourceAsync(String bucketId, String end, String start, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = getEventCountResourceValidateBeforeCall(bucketId, end, start, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } + /** + * Build call for getEventsResource + * @param bucketId (required) + * @param end End date of events (optional) + * @param start Start date of events (optional) + * @param limit the maximum number of requests to get (optional) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call getEventsResourceCall(String bucketId, String end, String start, String limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/0/buckets/{bucket_id}/events" + .replaceAll("\\{" + "bucket_id" + "\\}", apiClient.escapeString(bucketId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + if (end != null) + localVarQueryParams.addAll(apiClient.parameterToPair("end", end)); + if (start != null) + localVarQueryParams.addAll(apiClient.parameterToPair("start", start)); + if (limit != null) + localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit)); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call getEventsResourceValidateBeforeCall(String bucketId, String end, String start, String limit, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'bucketId' is set + if (bucketId == null) { + throw new ApiException("Missing the required parameter 'bucketId' when calling getEventsResource(Async)"); + } + + + com.squareup.okhttp.Call call = getEventsResourceCall(bucketId, end, start, limit, progressListener, progressRequestListener); + return call; + + } + + /** + * Get events from a bucket + * + * @param bucketId (required) + * @param end End date of events (optional) + * @param start Start date of events (optional) + * @param limit the maximum number of requests to get (optional) + * @return Event + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public Event getEventsResource(String bucketId, String end, String start, String limit) throws ApiException { + ApiResponse resp = getEventsResourceWithHttpInfo(bucketId, end, start, limit); + return resp.getData(); + } + + /** + * Get events from a bucket + * + * @param bucketId (required) + * @param end End date of events (optional) + * @param start Start date of events (optional) + * @param limit the maximum number of requests to get (optional) + * @return ApiResponse<Event> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getEventsResourceWithHttpInfo(String bucketId, String end, String start, String limit) throws ApiException { + com.squareup.okhttp.Call call = getEventsResourceValidateBeforeCall(bucketId, end, start, limit, null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Get events from a bucket (asynchronously) + * + * @param bucketId (required) + * @param end End date of events (optional) + * @param start Start date of events (optional) + * @param limit the maximum number of requests to get (optional) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call getEventsResourceAsync(String bucketId, String end, String start, String limit, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = getEventsResourceValidateBeforeCall(bucketId, end, start, limit, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } + /** + * Build call for getExportAllResource + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call getExportAllResourceCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/0/export"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call getExportAllResourceValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + + com.squareup.okhttp.Call call = getExportAllResourceCall(progressListener, progressRequestListener); + return call; + + } + + /** + * Exports all buckets and their events to a format consistent across versions + * + * @return Export + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public Export getExportAllResource() throws ApiException { + ApiResponse resp = getExportAllResourceWithHttpInfo(); + return resp.getData(); + } + + /** + * Exports all buckets and their events to a format consistent across versions + * + * @return ApiResponse<Export> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getExportAllResourceWithHttpInfo() throws ApiException { + com.squareup.okhttp.Call call = getExportAllResourceValidateBeforeCall(null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Exports all buckets and their events to a format consistent across versions (asynchronously) + * + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call getExportAllResourceAsync(final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = getExportAllResourceValidateBeforeCall(progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } + /** + * Build call for getInfoResource + * @param xFields An optional fields mask (optional) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call getInfoResourceCall(String xFields, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/0/info"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + if (xFields != null) + localVarHeaderParams.put("X-Fields", apiClient.parameterToString(xFields)); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call getInfoResourceValidateBeforeCall(String xFields, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + + com.squareup.okhttp.Call call = getInfoResourceCall(xFields, progressListener, progressRequestListener); + return call; + + } + + /** + * Get server info + * + * @param xFields An optional fields mask (optional) + * @return Info + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public Info getInfoResource(String xFields) throws ApiException { + ApiResponse resp = getInfoResourceWithHttpInfo(xFields); + return resp.getData(); + } + + /** + * Get server info + * + * @param xFields An optional fields mask (optional) + * @return ApiResponse<Info> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getInfoResourceWithHttpInfo(String xFields) throws ApiException { + com.squareup.okhttp.Call call = getInfoResourceValidateBeforeCall(xFields, null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Get server info (asynchronously) + * + * @param xFields An optional fields mask (optional) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call getInfoResourceAsync(String xFields, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = getInfoResourceValidateBeforeCall(xFields, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } + /** + * Build call for getLogResource + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call getLogResourceCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/0/log"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call getLogResourceValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + + com.squareup.okhttp.Call call = getLogResourceCall(progressListener, progressRequestListener); + return call; + + } + + /** + * Get the server log in json format + * + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void getLogResource() throws ApiException { + getLogResourceWithHttpInfo(); + } + + /** + * Get the server log in json format + * + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getLogResourceWithHttpInfo() throws ApiException { + com.squareup.okhttp.Call call = getLogResourceValidateBeforeCall(null, null); + return apiClient.execute(call); + } + + /** + * Get the server log in json format (asynchronously) + * + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call getLogResourceAsync(final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = getLogResourceValidateBeforeCall(progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } + /** + * Build call for postBucketResource + * @param bucketId (required) + * @param payload (required) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call postBucketResourceCall(String bucketId, CreateBucket payload, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = payload; + + // create path and map variables + String localVarPath = "/0/buckets/{bucket_id}" + .replaceAll("\\{" + "bucket_id" + "\\}", apiClient.escapeString(bucketId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call postBucketResourceValidateBeforeCall(String bucketId, CreateBucket payload, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'bucketId' is set + if (bucketId == null) { + throw new ApiException("Missing the required parameter 'bucketId' when calling postBucketResource(Async)"); + } + + // verify the required parameter 'payload' is set + if (payload == null) { + throw new ApiException("Missing the required parameter 'payload' when calling postBucketResource(Async)"); + } + + + com.squareup.okhttp.Call call = postBucketResourceCall(bucketId, payload, progressListener, progressRequestListener); + return call; + + } + + /** + * Create bucket + * Returns True if successful, otherwise false if a bucket with the given ID already existed. + * @param bucketId (required) + * @param payload (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void postBucketResource(String bucketId, CreateBucket payload) throws ApiException { + postBucketResourceWithHttpInfo(bucketId, payload); + } + + /** + * Create bucket + * Returns True if successful, otherwise false if a bucket with the given ID already existed. + * @param bucketId (required) + * @param payload (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse postBucketResourceWithHttpInfo(String bucketId, CreateBucket payload) throws ApiException { + com.squareup.okhttp.Call call = postBucketResourceValidateBeforeCall(bucketId, payload, null, null); + return apiClient.execute(call); + } + + /** + * Create bucket (asynchronously) + * Returns True if successful, otherwise false if a bucket with the given ID already existed. + * @param bucketId (required) + * @param payload (required) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call postBucketResourceAsync(String bucketId, CreateBucket payload, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = postBucketResourceValidateBeforeCall(bucketId, payload, progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } + /** + * Build call for postEventsResource + * @param bucketId (required) + * @param payload (required) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call postEventsResourceCall(String bucketId, Event payload, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = payload; + + // create path and map variables + String localVarPath = "/0/buckets/{bucket_id}/events" + .replaceAll("\\{" + "bucket_id" + "\\}", apiClient.escapeString(bucketId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call postEventsResourceValidateBeforeCall(String bucketId, Event payload, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'bucketId' is set + if (bucketId == null) { + throw new ApiException("Missing the required parameter 'bucketId' when calling postEventsResource(Async)"); + } + + // verify the required parameter 'payload' is set + if (payload == null) { + throw new ApiException("Missing the required parameter 'payload' when calling postEventsResource(Async)"); + } + + + com.squareup.okhttp.Call call = postEventsResourceCall(bucketId, payload, progressListener, progressRequestListener); + return call; + + } + + /** + * Create events for a bucket + * Can handle both single events and multiple ones. Returns the inserted event when a single event was inserted, otherwise None. + * @param bucketId (required) + * @param payload (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void postEventsResource(String bucketId, Event payload) throws ApiException { + postEventsResourceWithHttpInfo(bucketId, payload); + } + + /** + * Create events for a bucket + * Can handle both single events and multiple ones. Returns the inserted event when a single event was inserted, otherwise None. + * @param bucketId (required) + * @param payload (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse postEventsResourceWithHttpInfo(String bucketId, Event payload) throws ApiException { + com.squareup.okhttp.Call call = postEventsResourceValidateBeforeCall(bucketId, payload, null, null); + return apiClient.execute(call); + } + + /** + * Create events for a bucket (asynchronously) + * Can handle both single events and multiple ones. Returns the inserted event when a single event was inserted, otherwise None. + * @param bucketId (required) + * @param payload (required) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call postEventsResourceAsync(String bucketId, Event payload, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = postEventsResourceValidateBeforeCall(bucketId, payload, progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } + /** + * Build call for postHeartbeatResource + * @param bucketId (required) + * @param payload (required) + * @param pulsetime Largest timewindow allowed between heartbeats for them to merge (optional) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call postHeartbeatResourceCall(String bucketId, Event payload, String pulsetime, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = payload; + + // create path and map variables + String localVarPath = "/0/buckets/{bucket_id}/heartbeat" + .replaceAll("\\{" + "bucket_id" + "\\}", apiClient.escapeString(bucketId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + if (pulsetime != null) + localVarQueryParams.addAll(apiClient.parameterToPair("pulsetime", pulsetime)); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call postHeartbeatResourceValidateBeforeCall(String bucketId, Event payload, String pulsetime, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'bucketId' is set + if (bucketId == null) { + throw new ApiException("Missing the required parameter 'bucketId' when calling postHeartbeatResource(Async)"); + } + + // verify the required parameter 'payload' is set + if (payload == null) { + throw new ApiException("Missing the required parameter 'payload' when calling postHeartbeatResource(Async)"); + } + + + com.squareup.okhttp.Call call = postHeartbeatResourceCall(bucketId, payload, pulsetime, progressListener, progressRequestListener); + return call; + + } + + /** + * Heartbeats are useful when implementing watchers that simply keep + * track of a state, how long it's in that state and when it changes. A single heartbeat always has a duration of zero. If the heartbeat was identical to the last (apart from timestamp), then the last event has its duration updated. If the heartbeat differed, then a new event is created. Such as: - Active application and window title - Example: aw-watcher-window - Currently open document/browser tab/playing song - Example: wakatime - Example: aw-watcher-web - Example: aw-watcher-spotify - Is the user active/inactive? Send an event on some interval indicating if the user is active or not. - Example: aw-watcher-afk Inspired by: https://wakatime.com/developers#heartbeats + * @param bucketId (required) + * @param payload (required) + * @param pulsetime Largest timewindow allowed between heartbeats for them to merge (optional) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void postHeartbeatResource(String bucketId, Event payload, String pulsetime) throws ApiException { + postHeartbeatResourceWithHttpInfo(bucketId, payload, pulsetime); + } + + /** + * Heartbeats are useful when implementing watchers that simply keep + * track of a state, how long it's in that state and when it changes. A single heartbeat always has a duration of zero. If the heartbeat was identical to the last (apart from timestamp), then the last event has its duration updated. If the heartbeat differed, then a new event is created. Such as: - Active application and window title - Example: aw-watcher-window - Currently open document/browser tab/playing song - Example: wakatime - Example: aw-watcher-web - Example: aw-watcher-spotify - Is the user active/inactive? Send an event on some interval indicating if the user is active or not. - Example: aw-watcher-afk Inspired by: https://wakatime.com/developers#heartbeats + * @param bucketId (required) + * @param payload (required) + * @param pulsetime Largest timewindow allowed between heartbeats for them to merge (optional) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse postHeartbeatResourceWithHttpInfo(String bucketId, Event payload, String pulsetime) throws ApiException { + com.squareup.okhttp.Call call = postHeartbeatResourceValidateBeforeCall(bucketId, payload, pulsetime, null, null); + return apiClient.execute(call); + } + + /** + * Heartbeats are useful when implementing watchers that simply keep (asynchronously) + * track of a state, how long it's in that state and when it changes. A single heartbeat always has a duration of zero. If the heartbeat was identical to the last (apart from timestamp), then the last event has its duration updated. If the heartbeat differed, then a new event is created. Such as: - Active application and window title - Example: aw-watcher-window - Currently open document/browser tab/playing song - Example: wakatime - Example: aw-watcher-web - Example: aw-watcher-spotify - Is the user active/inactive? Send an event on some interval indicating if the user is active or not. - Example: aw-watcher-afk Inspired by: https://wakatime.com/developers#heartbeats + * @param bucketId (required) + * @param payload (required) + * @param pulsetime Largest timewindow allowed between heartbeats for them to merge (optional) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call postHeartbeatResourceAsync(String bucketId, Event payload, String pulsetime, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = postHeartbeatResourceValidateBeforeCall(bucketId, payload, pulsetime, progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } + /** + * Build call for postImportAllResource + * @param payload (required) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call postImportAllResourceCall(Export payload, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = payload; + + // create path and map variables + String localVarPath = "/0/import"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call postImportAllResourceValidateBeforeCall(Export payload, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'payload' is set + if (payload == null) { + throw new ApiException("Missing the required parameter 'payload' when calling postImportAllResource(Async)"); + } + + + com.squareup.okhttp.Call call = postImportAllResourceCall(payload, progressListener, progressRequestListener); + return call; + + } + + /** + * + * + * @param payload (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void postImportAllResource(Export payload) throws ApiException { + postImportAllResourceWithHttpInfo(payload); + } + + /** + * + * + * @param payload (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse postImportAllResourceWithHttpInfo(Export payload) throws ApiException { + com.squareup.okhttp.Call call = postImportAllResourceValidateBeforeCall(payload, null, null); + return apiClient.execute(call); + } + + /** + * (asynchronously) + * + * @param payload (required) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call postImportAllResourceAsync(Export payload, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = postImportAllResourceValidateBeforeCall(payload, progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } + /** + * Build call for postQueryResource + * @param payload (required) + * @param name Name of the query (required if using cache) (optional) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call postQueryResourceCall(Query payload, String name, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = payload; + + // create path and map variables + String localVarPath = "/0/query/"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + if (name != null) + localVarQueryParams.addAll(apiClient.parameterToPair("name", name)); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call postQueryResourceValidateBeforeCall(Query payload, String name, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'payload' is set + if (payload == null) { + throw new ApiException("Missing the required parameter 'payload' when calling postQueryResource(Async)"); + } + + + com.squareup.okhttp.Call call = postQueryResourceCall(payload, name, progressListener, progressRequestListener); + return call; + + } + + /** + * + * + * @param payload (required) + * @param name Name of the query (required if using cache) (optional) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void postQueryResource(Query payload, String name) throws ApiException { + postQueryResourceWithHttpInfo(payload, name); + } + + /** + * + * + * @param payload (required) + * @param name Name of the query (required if using cache) (optional) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse postQueryResourceWithHttpInfo(Query payload, String name) throws ApiException { + com.squareup.okhttp.Call call = postQueryResourceValidateBeforeCall(payload, name, null, null); + return apiClient.execute(call); + } + + /** + * (asynchronously) + * + * @param payload (required) + * @param name Name of the query (required if using cache) (optional) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call postQueryResourceAsync(Query payload, String name, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = postQueryResourceValidateBeforeCall(payload, name, progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } +} diff --git a/src/io/swagger/client/auth/ApiKeyAuth.java b/src/io/swagger/client/auth/ApiKeyAuth.java new file mode 100644 index 0000000..2c7711c --- /dev/null +++ b/src/io/swagger/client/auth/ApiKeyAuth.java @@ -0,0 +1,75 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams) { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if ("query".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } else if ("header".equals(location)) { + headerParams.put(paramName, value); + } + } +} diff --git a/src/io/swagger/client/auth/Authentication.java b/src/io/swagger/client/auth/Authentication.java new file mode 100644 index 0000000..7025435 --- /dev/null +++ b/src/io/swagger/client/auth/Authentication.java @@ -0,0 +1,29 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import java.util.Map; +import java.util.List; + +public interface Authentication { + /** + * Apply authentication settings to header and query params. + * + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + */ + void applyToParams(List queryParams, Map headerParams); +} diff --git a/src/io/swagger/client/auth/HttpBasicAuth.java b/src/io/swagger/client/auth/HttpBasicAuth.java new file mode 100644 index 0000000..d580740 --- /dev/null +++ b/src/io/swagger/client/auth/HttpBasicAuth.java @@ -0,0 +1,54 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import com.squareup.okhttp.Credentials; + +import java.util.Map; +import java.util.List; + +import java.io.UnsupportedEncodingException; + +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams) { + if (username == null && password == null) { + return; + } + headerParams.put("Authorization", Credentials.basic( + username == null ? "" : username, + password == null ? "" : password)); + } +} diff --git a/src/io/swagger/client/auth/OAuth.java b/src/io/swagger/client/auth/OAuth.java new file mode 100644 index 0000000..5e6ea0d --- /dev/null +++ b/src/io/swagger/client/auth/OAuth.java @@ -0,0 +1,39 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class OAuth implements Authentication { + private String accessToken; + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + @Override + public void applyToParams(List queryParams, Map headerParams) { + if (accessToken != null) { + headerParams.put("Authorization", "Bearer " + accessToken); + } + } +} diff --git a/src/io/swagger/client/auth/OAuthFlow.java b/src/io/swagger/client/auth/OAuthFlow.java new file mode 100644 index 0000000..50558d2 --- /dev/null +++ b/src/io/swagger/client/auth/OAuthFlow.java @@ -0,0 +1,18 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.auth; + +public enum OAuthFlow { + accessCode, implicit, password, application +} diff --git a/src/io/swagger/client/model/Bucket.java b/src/io/swagger/client/model/Bucket.java new file mode 100644 index 0000000..6a64d78 --- /dev/null +++ b/src/io/swagger/client/model/Bucket.java @@ -0,0 +1,268 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Event; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.threeten.bp.OffsetDateTime; + +/** + * The Bucket model that is used in ActivityWatch + */ +@ApiModel(description = "The Bucket model that is used in ActivityWatch") +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class Bucket { + @SerializedName("id") + private String id = null; + + @SerializedName("name") + private String name = null; + + @SerializedName("type") + private String type = null; + + @SerializedName("client") + private String client = null; + + @SerializedName("hostname") + private String hostname = null; + + @SerializedName("created") + private OffsetDateTime created = null; + + @SerializedName("data") + private Object data = null; + + @SerializedName("events") + private List events = null; + + public Bucket id(String id) { + this.id = id; + return this; + } + + /** + * The unique id for the bucket + * @return id + **/ + @ApiModelProperty(required = true, value = "The unique id for the bucket") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Bucket name(String name) { + this.name = name; + return this; + } + + /** + * The readable and renameable name for the bucket + * @return name + **/ + @ApiModelProperty(value = "The readable and renameable name for the bucket") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Bucket type(String type) { + this.type = type; + return this; + } + + /** + * The event type + * @return type + **/ + @ApiModelProperty(required = true, value = "The event type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Bucket client(String client) { + this.client = client; + return this; + } + + /** + * The name of the client that is reporting to the bucket + * @return client + **/ + @ApiModelProperty(required = true, value = "The name of the client that is reporting to the bucket") + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + public Bucket hostname(String hostname) { + this.hostname = hostname; + return this; + } + + /** + * The hostname of the machine on which the client is running + * @return hostname + **/ + @ApiModelProperty(required = true, value = "The hostname of the machine on which the client is running") + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public Bucket created(OffsetDateTime created) { + this.created = created; + return this; + } + + /** + * The creation datetime of the bucket + * @return created + **/ + @ApiModelProperty(value = "The creation datetime of the bucket") + public OffsetDateTime getCreated() { + return created; + } + + public void setCreated(OffsetDateTime created) { + this.created = created; + } + + public Bucket data(Object data) { + this.data = data; + return this; + } + + /** + * + * @return data + **/ + @ApiModelProperty(value = "") + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + + public Bucket events(List events) { + this.events = events; + return this; + } + + public Bucket addEventsItem(Event eventsItem) { + if (this.events == null) { + this.events = new ArrayList(); + } + this.events.add(eventsItem); + return this; + } + + /** + * Get events + * @return events + **/ + @ApiModelProperty(value = "") + public List getEvents() { + return events; + } + + public void setEvents(List events) { + this.events = events; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Bucket bucket = (Bucket) o; + return Objects.equals(this.id, bucket.id) && + Objects.equals(this.name, bucket.name) && + Objects.equals(this.type, bucket.type) && + Objects.equals(this.client, bucket.client) && + Objects.equals(this.hostname, bucket.hostname) && + Objects.equals(this.created, bucket.created) && + Objects.equals(this.data, bucket.data) && + Objects.equals(this.events, bucket.events); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, type, client, hostname, created, data, events); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Bucket {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" client: ").append(toIndentedString(client)).append("\n"); + sb.append(" hostname: ").append(toIndentedString(hostname)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" events: ").append(toIndentedString(events)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/io/swagger/client/model/CreateBucket.java b/src/io/swagger/client/model/CreateBucket.java new file mode 100644 index 0000000..56d3a45 --- /dev/null +++ b/src/io/swagger/client/model/CreateBucket.java @@ -0,0 +1,140 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * CreateBucket + */ +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class CreateBucket { + @SerializedName("client") + private String client = null; + + @SerializedName("type") + private String type = null; + + @SerializedName("hostname") + private String hostname = null; + + public CreateBucket client(String client) { + this.client = client; + return this; + } + + /** + * Get client + * @return client + **/ + @ApiModelProperty(required = true, value = "") + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + public CreateBucket type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @ApiModelProperty(required = true, value = "") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public CreateBucket hostname(String hostname) { + this.hostname = hostname; + return this; + } + + /** + * Get hostname + * @return hostname + **/ + @ApiModelProperty(required = true, value = "") + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateBucket createBucket = (CreateBucket) o; + return Objects.equals(this.client, createBucket.client) && + Objects.equals(this.type, createBucket.type) && + Objects.equals(this.hostname, createBucket.hostname); + } + + @Override + public int hashCode() { + return Objects.hash(client, type, hostname); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateBucket {\n"); + + sb.append(" client: ").append(toIndentedString(client)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" hostname: ").append(toIndentedString(hostname)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/io/swagger/client/model/Event.java b/src/io/swagger/client/model/Event.java new file mode 100644 index 0000000..262451b --- /dev/null +++ b/src/io/swagger/client/model/Event.java @@ -0,0 +1,143 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.math.BigDecimal; +import org.threeten.bp.OffsetDateTime; + +/** + * The Event model that is used in ActivityWatch + */ +@ApiModel(description = "The Event model that is used in ActivityWatch") +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class Event { + @SerializedName("timestamp") + private OffsetDateTime timestamp = null; + + @SerializedName("duration") + private BigDecimal duration = null; + + @SerializedName("data") + private Object data = null; + + public Event timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Get timestamp + * @return timestamp + **/ + @ApiModelProperty(required = true, value = "") + public OffsetDateTime getTimestamp() { + return timestamp; + } + + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + public Event duration(BigDecimal duration) { + this.duration = duration; + return this; + } + + /** + * Get duration + * @return duration + **/ + @ApiModelProperty(value = "") + public BigDecimal getDuration() { + return duration; + } + + public void setDuration(BigDecimal duration) { + this.duration = duration; + } + + public Event data(Object data) { + this.data = data; + return this; + } + + /** + * Get data + * @return data + **/ + @ApiModelProperty(value = "") + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Event event = (Event) o; + return Objects.equals(this.timestamp, event.timestamp) && + Objects.equals(this.duration, event.duration) && + Objects.equals(this.data, event.data); + } + + @Override + public int hashCode() { + return Objects.hash(timestamp, duration, data); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Event {\n"); + + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/io/swagger/client/model/Export.java b/src/io/swagger/client/model/Export.java new file mode 100644 index 0000000..4c8f66f --- /dev/null +++ b/src/io/swagger/client/model/Export.java @@ -0,0 +1,106 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Bucket; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * The Export model that is used by ActivityWatch + */ +@ApiModel(description = "The Export model that is used by ActivityWatch") +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class Export { + @SerializedName("buckets") + private List buckets = null; + + public Export buckets(List buckets) { + this.buckets = buckets; + return this; + } + + public Export addBucketsItem(Bucket bucketsItem) { + if (this.buckets == null) { + this.buckets = new ArrayList(); + } + this.buckets.add(bucketsItem); + return this; + } + + /** + * Get buckets + * @return buckets + **/ + @ApiModelProperty(value = "") + public List getBuckets() { + return buckets; + } + + public void setBuckets(List buckets) { + this.buckets = buckets; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Export export = (Export) o; + return Objects.equals(this.buckets, export.buckets); + } + + @Override + public int hashCode() { + return Objects.hash(buckets); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Export {\n"); + + sb.append(" buckets: ").append(toIndentedString(buckets)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/io/swagger/client/model/Info.java b/src/io/swagger/client/model/Info.java new file mode 100644 index 0000000..0aeec5a --- /dev/null +++ b/src/io/swagger/client/model/Info.java @@ -0,0 +1,163 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Info + */ +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class Info { + @SerializedName("hostname") + private String hostname = null; + + @SerializedName("version") + private String version = null; + + @SerializedName("testing") + private Boolean testing = null; + + @SerializedName("device_id") + private String deviceId = null; + + public Info hostname(String hostname) { + this.hostname = hostname; + return this; + } + + /** + * Get hostname + * @return hostname + **/ + @ApiModelProperty(value = "") + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public Info version(String version) { + this.version = version; + return this; + } + + /** + * Get version + * @return version + **/ + @ApiModelProperty(value = "") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public Info testing(Boolean testing) { + this.testing = testing; + return this; + } + + /** + * Get testing + * @return testing + **/ + @ApiModelProperty(value = "") + public Boolean isTesting() { + return testing; + } + + public void setTesting(Boolean testing) { + this.testing = testing; + } + + public Info deviceId(String deviceId) { + this.deviceId = deviceId; + return this; + } + + /** + * Get deviceId + * @return deviceId + **/ + @ApiModelProperty(value = "") + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Info info = (Info) o; + return Objects.equals(this.hostname, info.hostname) && + Objects.equals(this.version, info.version) && + Objects.equals(this.testing, info.testing) && + Objects.equals(this.deviceId, info.deviceId); + } + + @Override + public int hashCode() { + return Objects.hash(hostname, version, testing, deviceId); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Info {\n"); + + sb.append(" hostname: ").append(toIndentedString(hostname)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" testing: ").append(toIndentedString(testing)).append("\n"); + sb.append(" deviceId: ").append(toIndentedString(deviceId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/io/swagger/client/model/Query.java b/src/io/swagger/client/model/Query.java new file mode 100644 index 0000000..3fb45a4 --- /dev/null +++ b/src/io/swagger/client/model/Query.java @@ -0,0 +1,129 @@ +/* + * API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Query + */ +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2022-01-03T14:15:42.766Z") +public class Query { + @SerializedName("timeperiods") + private List timeperiods = new ArrayList(); + + @SerializedName("query") + private List query = new ArrayList(); + + public Query timeperiods(List timeperiods) { + this.timeperiods = timeperiods; + return this; + } + + public Query addTimeperiodsItem(String timeperiodsItem) { + this.timeperiods.add(timeperiodsItem); + return this; + } + + /** + * List of periods to query + * @return timeperiods + **/ + @ApiModelProperty(required = true, value = "List of periods to query") + public List getTimeperiods() { + return timeperiods; + } + + public void setTimeperiods(List timeperiods) { + this.timeperiods = timeperiods; + } + + public Query query(List query) { + this.query = query; + return this; + } + + public Query addQueryItem(String queryItem) { + this.query.add(queryItem); + return this; + } + + /** + * String list of query statements + * @return query + **/ + @ApiModelProperty(required = true, value = "String list of query statements") + public List getQuery() { + return query; + } + + public void setQuery(List query) { + this.query = query; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Query query = (Query) o; + return Objects.equals(this.timeperiods, query.timeperiods) && + Objects.equals(this.query, query.query); + } + + @Override + public int hashCode() { + return Objects.hash(timeperiods, query); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Query {\n"); + + sb.append(" timeperiods: ").append(toIndentedString(timeperiods)).append("\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} +