-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
.DS_Store | ||
*.iml | ||
.idea/* | ||
*.swp | ||
|
||
# npm | ||
node_modules/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
import MarathonService from "./services/MarathonService"; | ||
import MarathonActions from "./actions/MarathonActions"; | ||
|
||
const version = "0.0.1"; | ||
|
||
var PluginAPI = { | ||
version: version, | ||
MarathonService: MarathonService, | ||
MarathonActions: MarathonActions | ||
}; | ||
|
||
export default Object.freeze(PluginAPI); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import MarathonService from "../services/MarathonService"; | ||
import Utils from "../utils"; | ||
|
||
export default class MarathonActions { | ||
|
||
static getDeployments() { | ||
return MarathonService.request({ | ||
resource: "/v2/deployments" | ||
}); | ||
} | ||
|
||
static getGroup(group) { | ||
let groupName = Utils.addLeadingSlashIfNedded(group); | ||
return MarathonService.request({ | ||
resource: `/v2/groups${groupName}` | ||
}); | ||
} | ||
|
||
static getGroups() { | ||
return this.getGroup("/"); | ||
} | ||
|
||
static getApp(appId) { | ||
return MarathonService.request({ | ||
resource: `/v2/apps${appId}` | ||
}); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
import config from "../../../config/config"; | ||
import ajaxWrapper from "../../../helpers/ajaxWrapper"; | ||
import Utils from "../utils"; | ||
|
||
export default class MarathonService { | ||
|
||
static request(opts = {}) { | ||
let method = "GET"; | ||
let resource = Utils.addLeadingSlashIfNedded(opts.resource); | ||
|
||
if (opts.method) { | ||
method = opts.method; | ||
} | ||
|
||
return ajaxWrapper({ | ||
url: `${config.apiURL}${resource}`, | ||
method: method, | ||
data: opts.data | ||
}); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
export default class Utils { | ||
|
||
static addLeadingSlashIfNedded(value) { | ||
if (value && value[0] !== "/") { | ||
return "/" + value; | ||
} | ||
return value; | ||
}; | ||
|
||
}; |