Skip to content
Permalink
Browse files
Merge remote-tracking branch 'brooklyncentral-old/master' into initial
  • Loading branch information
ahgittin committed Feb 9, 2016
2 parents 3b86f40 + 63d33d4 commit 9d1f2c1be3c36fc840486000821f755cd438f91f
Show file tree
Hide file tree
Showing 68 changed files with 1,199 additions and 1,174 deletions.
@@ -1,6 +1,6 @@
package access_control

import(
import (
"encoding/json"
"fmt"
"github.com/brooklyncentral/brooklyn-cli/models"
@@ -9,12 +9,12 @@ import(

func Access(network *net.Network) (models.AccessSummary, error) {
url := fmt.Sprintf("/v1/access")
var access models.AccessSummary
var access models.AccessSummary

body, err := network.SendGetRequest(url)
if err != nil {
return access, err
}
body, err := network.SendGetRequest(url)
if err != nil {
return access, err
}

err = json.Unmarshal(body, &access)
return access, err
@@ -27,4 +27,4 @@ func Access(network *net.Network) (models.AccessSummary, error) {
// if err != nil {
// error_handler.ErrorExit(err)
// }
//}
//}
@@ -9,33 +9,33 @@ import (

func Activity(network *net.Network, activity string) (models.TaskSummary, error) {
url := fmt.Sprintf("/v1/activities/%s", activity)
var task models.TaskSummary
body, err := network.SendGetRequest(url)
if err != nil {
return task, err
}
var task models.TaskSummary
body, err := network.SendGetRequest(url)
if err != nil {
return task, err
}

err = json.Unmarshal(body, &task)
return task, err
}

func ActivityChildren(network *net.Network, activity string) ([]models.TaskSummary, error) {
url := fmt.Sprintf("/v1/activities/%s/children", activity)
var tasks []models.TaskSummary
body, err := network.SendGetRequest(url)
if err != nil {
return tasks, err
}
var tasks []models.TaskSummary
body, err := network.SendGetRequest(url)
if err != nil {
return tasks, err
}

err = json.Unmarshal(body, &tasks)
return tasks, err
}

func ActivityStream(network *net.Network, activity, streamId string) (string, error) {
func ActivityStream(network *net.Network, activity, streamId string) (string, error) {
url := fmt.Sprintf("/v1/activities/%s/stream/%s", activity, streamId)
body, err := network.SendGetRequest(url)
if nil != err {
return "", err
}
body, err := network.SendGetRequest(url)
if nil != err {
return "", err
}
return string(body), nil
}
@@ -20,95 +20,93 @@ func Fetch(network *net.Network) (string, error) {

func Applications(network *net.Network) ([]models.ApplicationSummary, error) {
url := fmt.Sprintf("/v1/applications")
var appSummary []models.ApplicationSummary
body, err := network.SendGetRequest(url)
if err != nil {
return appSummary, err
}
var appSummary []models.ApplicationSummary
body, err := network.SendGetRequest(url)
if err != nil {
return appSummary, err
}

err = json.Unmarshal(body, &appSummary)
return appSummary, err
}

func Create(network *net.Network, filePath string) (models.TaskSummary, error) {
url := "/v1/applications"
var response models.TaskSummary
body, err := network.SendPostFileRequest(url, filePath, "application/json")
if err != nil {
return response, err
}
var response models.TaskSummary
body, err := network.SendPostFileRequest(url, filePath, "application/json")
if err != nil {
return response, err
}
err = json.Unmarshal(body, &response)
return response, err
}

func CreateFromBytes(network *net.Network, blueprint []byte) (models.TaskSummary, error) {
url := "/v1/applications"
var response models.TaskSummary
body, err := network.SendPostRequest(url, blueprint)
if err != nil {
return response, err
}
var response models.TaskSummary
body, err := network.SendPostRequest(url, blueprint)
if err != nil {
return response, err
}
err = json.Unmarshal(body, &response)
return response, err
}

// WIP
func Descendants(network *net.Network, app string) (string, error) {
url := fmt.Sprintf("/v1/applications/%s/descendants", app)
url := fmt.Sprintf("/v1/applications/%s/descendants", app)

body, err := network.SendGetRequest(url)
// TODO return model
if nil != err {
return "", err
}
if nil != err {
return "", err
}
return string(body), nil
}

// WIP
func DescendantsSensor(network *net.Network, app, sensor string) (string, error) {
url := fmt.Sprintf("/v1/applications/%s/descendants/sensor/%s", app, sensor)
url := fmt.Sprintf("/v1/applications/%s/descendants/sensor/%s", app, sensor)

body, err := network.SendGetRequest(url)
// TODO return model
if nil != err {
return "", err
}
if nil != err {
return "", err
}
return string(body), nil
}

func Tree(network *net.Network) ([]models.Tree, error) {
url := "/v1/applications/tree"
var tree []models.Tree
body, err := network.SendGetRequest(url)
if err != nil {
return tree, err
}
var tree []models.Tree
body, err := network.SendGetRequest(url)
if err != nil {
return tree, err
}

err = json.Unmarshal(body, &tree)
return tree, err
}

func Application(network *net.Network, app string) (models.ApplicationSummary, error) {
url := fmt.Sprintf("/v1/applications/%s", app)
var appSummary models.ApplicationSummary
body, err := network.SendGetRequest(url)
if err != nil {
return appSummary, err
}
var appSummary models.ApplicationSummary
body, err := network.SendGetRequest(url)
if err != nil {
return appSummary, err
}

err = json.Unmarshal(body, &appSummary)
return appSummary, err
}



func Delete(network *net.Network, application string) (models.TaskSummary, error) {
url := fmt.Sprintf("/v1/applications/%s", application)
var response models.TaskSummary
body, err := network.SendDeleteRequest(url)
if err != nil {
return response, err
}
var response models.TaskSummary
body, err := network.SendDeleteRequest(url)
if err != nil {
return response, err
}
err = json.Unmarshal(body, &response)
return response, err
}
@@ -123,5 +121,3 @@ func CreateLegacy(network *net.Network) (string, error) {
// TODO return model
return string(body), nil
}


0 comments on commit 9d1f2c1

Please sign in to comment.