You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by an...@apache.org on 2016/09/10 17:14:45 UTC
[08/10] brooklyn-client git commit: move rest-client to
brooklyn-client
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/api/usage/usage.go
----------------------------------------------------------------------
diff --git a/api/usage/usage.go b/api/usage/usage.go
deleted file mode 100644
index f49a517..0000000
--- a/api/usage/usage.go
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package usage
-
-import (
- "encoding/json"
- "fmt"
- "github.com/apache/brooklyn-client/models"
- "github.com/apache/brooklyn-client/net"
-)
-
-func Application(network *net.Network, application string) (string, error) {
- url := fmt.Sprintf("/v1/usage/applications/%s", application)
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func Applications(network *net.Network) (string, error) {
- url := fmt.Sprintf("/v1/usage/applications")
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func Machine(network *net.Network, machine string) (string, error) {
- url := fmt.Sprintf("/v1/usage/machines/%s", machine)
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func Machines(network *net.Network) (string, error) {
- url := fmt.Sprintf("/v1/usage/machines")
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/api/version/version.go
----------------------------------------------------------------------
diff --git a/api/version/version.go b/api/version/version.go
deleted file mode 100644
index c3f1c70..0000000
--- a/api/version/version.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package version
-
-import (
- "encoding/json"
- "github.com/apache/brooklyn-client/models"
- "github.com/apache/brooklyn-client/net"
-)
-
-func Version(network *net.Network) (models.VersionSummary, error) {
- url := "/v1/server/version"
- var versionSummary models.VersionSummary
- body, err := network.SendGetRequest(url)
- if err != nil {
- return versionSummary, err
- }
- err = json.Unmarshal(body, &versionSummary)
- return versionSummary, err
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/app/app.go
----------------------------------------------------------------------
diff --git a/app/app.go b/app/app.go
deleted file mode 100644
index afdb41d..0000000
--- a/app/app.go
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package app
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/command_runner"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/urfave/cli"
- "os"
- "strings"
-)
-
-type configDefaults struct {
- Name string
- HelpName string
- Usage string
- Version string
-}
-
-var appConfig = configDefaults{
- Name: os.Args[0],
- HelpName: os.Args[0],
- Usage: "A Brooklyn command line client application",
- Version: "0.10.0-SNAPSHOT", // BROOKLYN_VERSION
-}
-
-func NewApp(baseName string, cmdRunner command_runner.Runner, metadatas ...command_metadata.CommandMetadata) (app *cli.App) {
-
- cli.AppHelpTemplate = appHelpTemplate()
- cli.CommandHelpTemplate = commandHelpTemplate()
- app = cli.NewApp()
- app.Name = appConfig.Name
- app.HelpName = appConfig.HelpName
- app.Usage = appConfig.Usage
- app.Version = appConfig.Version
-
- app.Flags = []cli.Flag{
- cli.BoolFlag{
- Name: "skipSslChecks",
- Usage: "Skip verification of server's certificate chain and hostname (for use with self-signed certs)",
- },
- }
-
- app.Commands = []cli.Command{}
-
- for _, metadata := range metadatas {
- primaryCommand := getCommand(baseName, metadata, cmdRunner)
- app.Commands = append(app.Commands, primaryCommand)
- }
- return
-}
-
-func getCommand(baseName string, metadata command_metadata.CommandMetadata, runner command_runner.Runner) cli.Command {
- command := cli.Command{
- Name: metadata.Name,
- Aliases: metadata.Aliases,
- ShortName: metadata.ShortName,
- Description: metadata.Description,
- Usage: strings.Replace(metadata.Usage, "BROOKLYN_NAME", baseName, -1),
- Action: func(context *cli.Context) {
- err := runner.RunCmdByName(metadata.Name, context)
- if err != nil {
- error_handler.ErrorExit(err)
- }
- },
- Flags: metadata.Flags,
- SkipFlagParsing: metadata.SkipFlagParsing,
- }
-
- if nil != metadata.Operands {
- command.Subcommands = make([]cli.Command, 0)
- for _, operand := range metadata.Operands {
- command.Subcommands = append(command.Subcommands, cli.Command{
- Name: operand.Name,
- Aliases: operand.Aliases,
- ShortName: operand.ShortName,
- Description: operand.Description,
- Usage: operand.Usage,
- Flags: operand.Flags,
- SkipFlagParsing: operand.SkipFlagParsing,
- Action: subCommandAction(command.Name, operand.Name, runner),
- })
- command.Usage = strings.Join([]string{
- command.Usage, "\n... ", operand.Usage, "\t", operand.Description,
- }, "")
- }
- }
-
- return command
-}
-
-func subCommandAction(command string, operand string, runner command_runner.Runner) func(context *cli.Context) {
- return func(context *cli.Context) {
- err := runner.RunSubCmdByName(command, operand, context)
- if err != nil {
- fmt.Fprintln(os.Stderr, err)
- }
- }
-}
-
-func appHelpTemplate() string {
- return `NAME:
- {{.Name}} - {{.Usage}}
-USAGE:
- {{.Name}} {{if .Flags}}[global options] {{end}}command{{if .Flags}} [command options]{{end}} [arguments...]
-
-VERSION:
- {{.Version}}{{if or .Author .Email}}
-
-AUTHOR:{{if .Author}}
- {{.Author}}{{if .Email}} - <{{.Email}}>{{end}}{{else}}
- {{.Email}}{{end}}{{end}}
-
-
-SCOPES:
- Many commands require a "scope" expression to indicate the target on which they operate. The scope expressions are
- as follows (values in brackets are aliases for the scope):
- - application APP-ID (app, a) Selects and application, e.g. "br app myapp"
- - entity ENT-ID (ent, e) Selects an entity within an application scope, e.g. "br app myapp ent myserver"
- - effector EFF-ID (eff, f) Selects an effector of an entity or application, e.g. "br a myapp e myserver eff xyz"
- - config CONF-KEY (conf, con, c) Selects a configuration key of an entity e.g. "br a myapp e myserver config jmx.agent.mode"
- - activity ACT-ID (act, v) Selects an activity of an entity e.g. "br a myapp e myserver act iHG7sq1"
-
-
-COMMANDS:
-
- Commands whose description begins with a "*" character are particularly experimental and likely to change in upcoming
- releases. If not otherwise specified, "SCOPE" below means application or entity scope. If an entity scope is not
- specified, the application entity is used as a default.
-
- {{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Description}}
- {{end}}{{if .Flags}}
-GLOBAL OPTIONS:
- {{range .Flags}}{{.}}
- {{end}}{{end}}
-`
-}
-
-func commandHelpTemplate() string {
- return `NAME:
- {{.Name}} - {{.Description}}
-{{with .ShortName}}
-ALIAS:
- {{.}}
-{{end}}
-USAGE:
- {{.Usage}}{{with .Flags}}
-OPTIONS:
-{{range .}} {{.}}
-{{end}}{{else}}
-{{end}}`
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/br/brooklyn.go
----------------------------------------------------------------------
diff --git a/br/brooklyn.go b/br/brooklyn.go
deleted file mode 100644
index 7f5eed5..0000000
--- a/br/brooklyn.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package main
-
-import (
- "github.com/apache/brooklyn-client/app"
- "github.com/apache/brooklyn-client/command_factory"
- "github.com/apache/brooklyn-client/command_runner"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/io"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "os"
- "path/filepath"
-)
-
-func getNetworkCredentialsFromConfig(yamlMap map[string]interface{}) (string, string, string, bool) {
- var target, username, password string
- var skipSslChecks bool
- target, found := yamlMap["target"].(string)
- if found {
- auth, found := yamlMap["auth"].(map[string]interface{})
- if found {
- creds := auth[target].(map[string]interface{})
- username, found = creds["username"].(string)
- if found {
- password, found = creds["password"].(string)
- }
- }
- skipSslChecks, _ = yamlMap["skipSslChecks"].(bool)
- }
- return target, username, password, skipSslChecks
-}
-
-func main() {
- config := io.GetConfig()
- target, username, password, skipSslChecks := getNetworkCredentialsFromConfig(config.Map)
- //target, username, password := "http://192.168.50.101:8081", "brooklyn", "Sns4Hh9j7l"
- network := net.NewNetwork(target, username, password, skipSslChecks)
- cmdFactory := command_factory.NewFactory(network, config)
-
- args, scope := scope.ScopeArguments(os.Args)
- cmdRunner := command_runner.NewRunner(scope, cmdFactory)
- metaDatas := cmdFactory.CommandMetadatas()
- theApp := app.NewApp(filepath.Base(args[0]), cmdRunner, metaDatas...)
- if err := theApp.Run(args); nil != err {
- error_handler.ErrorExit(err)
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
deleted file mode 100644
index 713b339..0000000
--- a/build.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project name="CLI" >
- <condition property="platform.extension" value=".bat" else=".sh">
- <os family="windows" />
- </condition>
- <property name="build.script" location="${basedir}/release/build${platform.extension}"/>
-
- <target name="all" >
- <exec executable="${build.script}" failonerror="true">
- <arg value="-A"/>
- <arg value="-t"/>
- <arg value="-d"/>
- <arg value="${project.build.directory}"/>
- <arg value="-s"/>
- <arg value="${basedir}"/>
- </exec>
- </target>
-
- <target name="cross" >
- <exec executable="${build.script}" failonerror="true">
- <arg value="-t"/>
- <arg value="-a"/>
- <arg value="${arch}"/>
- <arg value="-o"/>
- <arg value="${os}"/>
- <arg value="-d"/>
- <arg value="${project.build.directory}"/>
- <arg value="-s"/>
- <arg value="${basedir}"/>
- </exec>
- </target>
-
- <target name="native" >
- <exec executable="${build.script}" failonerror="true">
- <arg value="-d"/>
- <arg value="${project.build.directory}"/>
- <arg value="-s"/>
- <arg value="${basedir}"/>
- </exec>
- </target>
-
-</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/LICENSE
----------------------------------------------------------------------
diff --git a/cli/LICENSE b/cli/LICENSE
new file mode 100644
index 0000000..9764158
--- /dev/null
+++ b/cli/LICENSE
@@ -0,0 +1,445 @@
+
+This software is distributed under the Apache License, version 2.0. See (1) below.
+This software is copyright (c) The Apache Software Foundation and contributors.
+
+Contents:
+
+ (1) This software license: Apache License, version 2.0
+ (2) Notices for bundled software
+ (3) Licenses for bundled software
+
+
+---------------------------------------------------
+
+(1) This software license: Apache License, version 2.0
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+
+---------------------------------------------------
+
+(2) Notices for bundled software
+
+This project includes the software: github.com/urfave/cli
+ Available at: https://github.com/urfave/cli
+ Used under the following license: The MIT License (http://opensource.org/licenses/MIT)
+ Copyright (C) 2013 Jeremy Saenz
+
+This project includes the software: golang.org/x/crypto/ssh
+ Available at: https://godoc.org/golang.org/x/crypto/ssh
+ Used under the following license: The BSD 3-Clause (New BSD) License (http://opensource.org/licenses/BSD-3-Clause)
+ Copyright (c) 2009 The Go Authors. All rights reserved.
+
+
+---------------------------------------------------
+
+(3) Licenses for bundled software
+
+Contents:
+
+ Apache License, Version 2.0
+ The BSD 3-Clause License ("New BSD")
+ The MIT License ("MIT")
+
+
+Apache License, Version 2.0
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+
+The BSD 3-Clause License ("New BSD")
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+
+The MIT License ("MIT")
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/NOTICE
----------------------------------------------------------------------
diff --git a/cli/NOTICE b/cli/NOTICE
new file mode 100644
index 0000000..6d1f608
--- /dev/null
+++ b/cli/NOTICE
@@ -0,0 +1,5 @@
+Apache Brooklyn
+Copyright 2014-2016 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/README.md
----------------------------------------------------------------------
diff --git a/cli/README.md b/cli/README.md
new file mode 100644
index 0000000..1602759
--- /dev/null
+++ b/cli/README.md
@@ -0,0 +1,118 @@
+
+# [](http://brooklyn.apache.org/)
+
+### Apache Brooklyn Client CLI
+
+A command line client for [Apache Brooklyn](https://brooklyn.apache.org).
+
+## Toolchain
+
+The CLI tool is written in Go and should be obtained and built as a standard Go project.
+You will need the following tools to build it:
+
+- Go (version 1.6.1 or higher), with full cross-compiler support (see https://golang.org/dl).
+ On Mac, if using Homebrew, use "brew install go --with-cc-all"
+
+Optional:
+- Maven (used by the Brooklyn build process)
+
+- Maven (see note below on the Brooklyn build process)
+
+
+## Workspace Setup
+
+Go is very particular about the layout of a source tree, and the naming of packages. It is therefore important to
+get the code from github.com/apache/brooklyn-client/cli and not your own fork. If you want to contribute to the
+project, the procedure to follow is still to get the code from github.com/apache/brooklyn-client/cli, and then to add your
+own fork as a remote.
+
+- Ensure your [$GOPATH](http://golang.org/cmd/go/#hdr-GOPATH_environment_variable) is set correctly
+ to a suitable location for your Go code, for example, simply $HOME/go.
+- Get the Brooklyn CLI and dependencies.
+
+```bash
+go get github.com/apache/brooklyn-client/cli/br
+```
+
+
+## Installing Dependencies
+
+The CLI has a small number of dependencies, notably on `urfave/cli`. To manage the version of dependencies, the CLI
+code currently uses [Glide](https://github.com/Masterminds/glide). The dependencies are installed to the top level 'vendor' directory.
+
+```bash
+go get github.com/Masterminds/glide
+cd $GOPATH/src/github.com/apache/brooklyn-client/cli
+glide install
+```
+
+## Compiling the code with Go for development purposes
+
+Just use the regular Go build commands.
+
+
+## Testing
+
+The code includes a test script in the [test](test) directory. This deploys a Tomcat server on a location of your choice
+and runs a number of tests against it, to verify that the br commands perform as expected. To use this you must edit
+the file "test_app.yaml" to change the location to your own value, and then invoke the test script like the following,
+where the username and password need only be supplied if Brooklyn requires them:
+
+```bash
+sh test.sh http://your-brooklyn-host:8081 myuser mypassword
+```
+
+Note, the tests are not yet comprehensive, and contributions are welcome.
+
+## Building the code as part of the Brooklyn build process
+
+For consistency with the other sub-projects of the overall [Brooklyn](https://github.com/apache/brooklyn) build, Maven
+is used to perform the build when brooklyn-client is built as one of the sub-modules of Brooklyn. Most of the work is
+delegated to the release/build.sh script, which cross-compiles the code for a number of platform-architecture combinations.
+
+Invoke the build script via Maven with one of
+
+ - ```mvn clean install``` build for all supported platforms
+ - ```mvn -Dtarget=native clean install``` build for the current platform
+ - ```mvn -Dtarget=cross -Dos=OS -Darch=ARCH clean install``` build for platform with operating system OS and architecture ARCH
+
+*NOTE* This does *not* build the code into your usual GOPATH. To allow the project to be checked out along with the
+other Brooklyn submodules and built using Maven, without any special treatment to install it into a separate GOPATH
+location, the Maven build makes no assumption about the location of the project root directory. Instead, the Maven
+`target` directory is used as the GOPATH, and a soft link is created as `target/src/github.com/apache/brooklyn-cli` to
+the code in the root directory.
+
+This builds the requested binaries into the "target" directory, each in its own subdirectory with a name that includes
+the platform/architecture details, e.g. bin/linux.386/br. The build installs a maven artifact to the maven repository,
+consisting of a zip file containing all the binaries. This artifact can be referenced in a POM as
+
+```xml
+<groupId>org.apache.brooklyn</groupId>
+<artifactId>brooklyn-client-cli</artifactId>
+<classifier>bin</classifier>
+<type>zip</type>
+<version>...</version>
+```
+
+
+## Running
+
+See instructions in the included [Runtime README](release/files/README) file.
+
+----
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/access_control/access_control.go
----------------------------------------------------------------------
diff --git a/cli/api/access_control/access_control.go b/cli/api/access_control/access_control.go
new file mode 100644
index 0000000..c68eecf
--- /dev/null
+++ b/cli/api/access_control/access_control.go
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package access_control
+
+import (
+ "encoding/json"
+ "fmt"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+)
+
+func Access(network *net.Network) (models.AccessSummary, error) {
+ url := fmt.Sprintf("/v1/access")
+ var access models.AccessSummary
+
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return access, err
+ }
+
+ err = json.Unmarshal(body, &access)
+ return access, err
+}
+
+// WIP
+//func LocationProvisioningAllowed(network *net.Network, allowed bool) {
+// url := fmt.Sprintf("/v1/access/locationProvisioningAllowed")
+// body, err := network.SendPostRequest(url)
+// if err != nil {
+// error_handler.ErrorExit(err)
+// }
+//}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/activities/activities.go
----------------------------------------------------------------------
diff --git a/cli/api/activities/activities.go b/cli/api/activities/activities.go
new file mode 100644
index 0000000..0364dcb
--- /dev/null
+++ b/cli/api/activities/activities.go
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package activities
+
+import (
+ "encoding/json"
+ "fmt"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+)
+
+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
+ }
+
+ 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
+ }
+
+ err = json.Unmarshal(body, &tasks)
+ return tasks, err
+}
+
+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
+ }
+ return string(body), nil
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/application/applications.go
----------------------------------------------------------------------
diff --git a/cli/api/application/applications.go b/cli/api/application/applications.go
new file mode 100644
index 0000000..f46ebac
--- /dev/null
+++ b/cli/api/application/applications.go
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package application
+
+import (
+ "encoding/json"
+ "fmt"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+)
+
+//WIP
+func Fetch(network *net.Network) (string, error) {
+ url := "/v1/applications/fetch"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ // TODO return model
+ return string(body), nil
+}
+
+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
+ }
+
+ err = json.Unmarshal(body, &appSummary)
+ return appSummary, err
+}
+
+func Create(network *net.Network, resource string) (models.TaskSummary, error) {
+ url := "/v1/applications"
+ var response models.TaskSummary
+ body, err := network.SendPostResourceRequest(url, resource, "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
+ }
+ 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)
+
+ body, err := network.SendGetRequest(url)
+ // TODO return model
+ 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)
+
+ body, err := network.SendGetRequest(url)
+ // TODO return model
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Tree(network *net.Network) ([]models.Tree, error) {
+ url := "/v1/applications/fetch"
+ 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
+ }
+
+ 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
+ }
+ err = json.Unmarshal(body, &response)
+ return response, err
+}
+
+// WIP
+func CreateLegacy(network *net.Network) (string, error) {
+ url := fmt.Sprintf("/v1/applications/createLegacy")
+ body, err := network.SendEmptyPostRequest(url)
+ if err != nil {
+ return "", err
+ }
+ // TODO return model
+ return string(body), nil
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/catalog/catalog.go
----------------------------------------------------------------------
diff --git a/cli/api/catalog/catalog.go b/cli/api/catalog/catalog.go
new file mode 100644
index 0000000..dd5b75a
--- /dev/null
+++ b/cli/api/catalog/catalog.go
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package catalog
+
+import (
+ "encoding/json"
+ "fmt"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+)
+
+func Icon(network *net.Network, itemId string) ([]byte, error) {
+ url := fmt.Sprintf("/v1/catalog/icon/%s", itemId)
+ body, err := network.SendGetRequest(url)
+ return body, err
+}
+
+func IconWithVersion(network *net.Network, itemId, version string) ([]byte, error) {
+ url := fmt.Sprintf("/v1/catalog/icon/%s/%s", itemId, version)
+ body, err := network.SendGetRequest(url)
+ return body, err
+}
+
+func GetEntityWithVersion(network *net.Network, entityId, version string) (models.CatalogEntitySummary, error) {
+ url := fmt.Sprintf("/v1/catalog/entities/%s/%s", entityId, version)
+ var catalogEntity models.CatalogEntitySummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return catalogEntity, err
+ }
+ err = json.Unmarshal(body, &catalogEntity)
+ return catalogEntity, err
+}
+
+func DeleteEntityWithVersion(network *net.Network, entityId, version string) (string, error) {
+ url := fmt.Sprintf("/v1/catalog/entities/%s/%s", entityId, version)
+ body, err := network.SendDeleteRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func GetEntity(network *net.Network, entityId string) (models.CatalogEntitySummary, error) {
+ url := fmt.Sprintf("/v1/catalog/entities/%s", entityId)
+ var catalogEntity models.CatalogEntitySummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return catalogEntity, err
+ }
+ err = json.Unmarshal(body, &catalogEntity)
+ return catalogEntity, err
+}
+
+func DeleteEntity(network *net.Network, entityId string) (string, error) {
+ url := fmt.Sprintf("/v1/catalog/entities/%s", entityId)
+ body, err := network.SendDeleteRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func GetPolicy(network *net.Network, policyId string) (models.CatalogItemSummary, error) {
+ url := fmt.Sprintf("/v1/catalog/policies/%s", policyId)
+ var catalogItem models.CatalogItemSummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return catalogItem, err
+ }
+ err = json.Unmarshal(body, &catalogItem)
+ return catalogItem, err
+}
+
+func GetPolicyWithVersion(network *net.Network, policyId, version string) (models.CatalogItemSummary, error) {
+ url := fmt.Sprintf("/v1/catalog/policies/%s/%s", policyId)
+ var catalogItem models.CatalogItemSummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return catalogItem, err
+ }
+ err = json.Unmarshal(body, &catalogItem)
+ return catalogItem, err
+}
+
+func DeletePolicyWithVersion(network *net.Network, policyId, version string) (string, error) {
+ url := fmt.Sprintf("/v1/catalog/policies/%s/%s", policyId)
+ body, err := network.SendDeleteRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func GetApplication(network *net.Network, applicationId string) (models.CatalogEntitySummary, error) {
+ url := fmt.Sprintf("/v1/catalog/applications/%s", applicationId)
+ var catalogEntity models.CatalogEntitySummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return catalogEntity, err
+ }
+ err = json.Unmarshal(body, &catalogEntity)
+ return catalogEntity, err
+}
+
+func GetApplicationWithVersion(network *net.Network, applicationId, version string) (models.CatalogEntitySummary, error) {
+ url := fmt.Sprintf("/v1/catalog/applications/%s/%s", applicationId, version)
+ var catalogEntity models.CatalogEntitySummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return catalogEntity, err
+ }
+ err = json.Unmarshal(body, &catalogEntity)
+ return catalogEntity, err
+}
+
+func DeleteApplicationWithVersion(network *net.Network, applicationId, version string) (string, error) {
+ url := fmt.Sprintf("/v1/catalog/applications/%s/%s", applicationId, version)
+ body, err := network.SendDeleteRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Policies(network *net.Network) ([]models.CatalogPolicySummary, error) {
+ url := "/v1/catalog/policies"
+ var policies []models.CatalogPolicySummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return policies, err
+ }
+ err = json.Unmarshal(body, &policies)
+ return policies, err
+}
+
+func Locations(network *net.Network) (models.CatalogLocationSummary, error) {
+ url := "/v1/catalog/locations"
+ var catalogLocation models.CatalogLocationSummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return catalogLocation, err
+ }
+ err = json.Unmarshal(body, &catalogLocation)
+ return catalogLocation, err
+}
+
+func AddCatalog(network *net.Network, resource string) (string, error) {
+ url := "/v1/catalog"
+ body, err := network.SendPostResourceRequest(url, resource, "application/json")
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Reset(network *net.Network) (string, error) {
+ url := "/v1/catalog/reset"
+ body, err := network.SendEmptyPostRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func GetLocationWithVersion(network *net.Network, locationId, version string) (models.CatalogLocationSummary, error) {
+ url := fmt.Sprintf("/v1/catalog/locations/%s/%s", locationId, version)
+ var catalogLocation models.CatalogLocationSummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return catalogLocation, err
+ }
+ err = json.Unmarshal(body, &catalogLocation)
+ return catalogLocation, err
+}
+
+func PostLocationWithVersion(network *net.Network, locationId, version string) (string, error) {
+ url := fmt.Sprintf("/v1/catalog/locations/%s/%s", locationId, version)
+ body, err := network.SendEmptyPostRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Entities(network *net.Network) ([]models.CatalogItemSummary, error) {
+ url := "/v1/catalog/entities"
+ var entities []models.CatalogItemSummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return entities, err
+ }
+ err = json.Unmarshal(body, &entities)
+ return entities, err
+}
+
+func Catalog(network *net.Network) ([]models.CatalogItemSummary, error) {
+ url := "/v1/catalog/applications"
+ var applications []models.CatalogItemSummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return applications, err
+ }
+ err = json.Unmarshal(body, &applications)
+ return applications, err
+}
+
+func GetLocation(network *net.Network, locationId string) (models.CatalogLocationSummary, error) {
+ url := fmt.Sprintf("/v1/catalog/locations/%s", locationId)
+ var catalogLocation models.CatalogLocationSummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return catalogLocation, err
+ }
+ err = json.Unmarshal(body, &catalogLocation)
+ return catalogLocation, err
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/entities/entities.go
----------------------------------------------------------------------
diff --git a/cli/api/entities/entities.go b/cli/api/entities/entities.go
new file mode 100644
index 0000000..90dbb49
--- /dev/null
+++ b/cli/api/entities/entities.go
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package entities
+
+import (
+ "encoding/json"
+ "fmt"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+ "net/url"
+)
+
+//WIP
+func GetTask(network *net.Network, application, entity, task string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/activities/%s", application, entity, task)
+ body, err := network.SendGetRequest(url)
+ // TODO return model
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+//WIP
+func GetIcon(network *net.Network, application, entity string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/icon", application, entity)
+ body, err := network.SendGetRequest(url)
+ // TODO return model
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Children(network *net.Network, application, entity string) ([]models.EntitySummary, error) {
+ urlStr := fmt.Sprintf("/v1/applications/%s/entities/%s/children", application, entity)
+ var entityList []models.EntitySummary
+ body, err := network.SendGetRequest(urlStr)
+ if err != nil {
+ return entityList, err
+ }
+
+ err = json.Unmarshal(body, &entityList)
+ return entityList, err
+}
+
+func AddChildren(network *net.Network, application, entity, resource string) (models.TaskSummary, error) {
+ urlStr := fmt.Sprintf("/v1/applications/%s/entities/%s/children", application, entity)
+ var response models.TaskSummary
+ body, err := network.SendPostResourceRequest(urlStr, resource, "application/json")
+ if err != nil {
+ return response, err
+ }
+
+ err = json.Unmarshal(body, &response)
+ return response, err
+}
+
+//WIP
+func GetLocations(network *net.Network, application, entity string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/locations", application, entity)
+ body, err := network.SendGetRequest(url)
+ // TODO return model
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Spec(network *net.Network, application, entity string) (string, error) {
+ urlStr := fmt.Sprintf("/v1/applications/%s/entities/%s/spec", application, entity)
+ body, err := network.SendGetRequest(urlStr)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+//WIP
+func GetDescendants(network *net.Network, application, entity string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/descendants", application, entity)
+ body, err := network.SendGetRequest(url)
+ // TODO return model
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+//WIP
+func GetDescendantsSensor(network *net.Network, application, entity, sensor string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/descendants/sensor/%s", application, entity, sensor)
+ body, err := network.SendGetRequest(url)
+ // TODO return model
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func GetActivities(network *net.Network, application, entity string) ([]models.TaskSummary, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/activities", application, entity)
+ var activityList []models.TaskSummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return activityList, err
+ }
+
+ err = json.Unmarshal(body, &activityList)
+ return activityList, err
+}
+
+//WIP
+func GetTags(network *net.Network, application, entity string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/tags", application, entity)
+ body, err := network.SendGetRequest(url)
+ // TODO return model
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+//WIP
+func Expunge(network *net.Network, application, entity string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/expunge", application, entity)
+ body, err := network.SendEmptyPostRequest(url)
+ // TODO return model
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+//WIP
+func GetEntity(network *net.Network, application, entity string) (models.EntitySummary, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s", application, entity)
+ summary := models.EntitySummary{}
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return summary, err
+ }
+
+ err = json.Unmarshal(body, &summary)
+ return summary, err
+}
+
+func EntityList(network *net.Network, application string) ([]models.EntitySummary, error) {
+ urlStr := fmt.Sprintf("/v1/applications/%s/entities", application)
+ var entityList []models.EntitySummary
+ body, err := network.SendGetRequest(urlStr)
+ if err != nil {
+ return entityList, err
+ }
+
+ err = json.Unmarshal(body, &entityList)
+ return entityList, err
+}
+
+func Rename(network *net.Network, application, entity, newName string) (string, error) {
+ urlStr := fmt.Sprintf("/v1/applications/%s/entities/%s/name?name=%s", application, entity, url.QueryEscape(newName))
+ body, err := network.SendEmptyPostRequest(urlStr)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/entity_config/config.go
----------------------------------------------------------------------
diff --git a/cli/api/entity_config/config.go b/cli/api/entity_config/config.go
new file mode 100644
index 0000000..66cd1d5
--- /dev/null
+++ b/cli/api/entity_config/config.go
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package entity_config
+
+import (
+ "encoding/json"
+ "fmt"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+)
+
+func ConfigValue(network *net.Network, application, entity, config string) (interface{}, error) {
+ bytes, err := ConfigValueAsBytes(network, application, entity, config)
+ if nil != err || 0 == len(bytes) {
+ return nil, err
+ }
+
+ var value interface{}
+ err = json.Unmarshal(bytes, &value)
+ if nil != err {
+ return nil, err
+ }
+
+ return value, nil
+}
+
+func ConfigValueAsBytes(network *net.Network, application, entity, config string) ([]byte, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/config/%s", application, entity, config)
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return []byte{}, err
+ }
+
+ return body, nil
+}
+
+func SetConfig(network *net.Network, application, entity, config, value string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/config/%s", application, entity, config)
+ val := []byte(value)
+ body, err := network.SendPostRequest(url, val)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func ConfigList(network *net.Network, application, entity string) ([]models.ConfigSummary, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/config", application, entity)
+ var configList []models.ConfigSummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return configList, err
+ }
+
+ err = json.Unmarshal(body, &configList)
+ return configList, err
+}
+
+func PostConfig(network *net.Network, application, entity, config, value string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/config", application, entity)
+ val := []byte(value)
+ body, err := network.SendPostRequest(url, val)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func ConfigCurrentState(network *net.Network, application, entity string) (map[string]interface{}, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/config/current-state", application, entity)
+ var currentState map[string]interface{}
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return currentState, err
+ }
+ err = json.Unmarshal(body, ¤tState)
+ return currentState, err
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/entity_effectors/effectors.go
----------------------------------------------------------------------
diff --git a/cli/api/entity_effectors/effectors.go b/cli/api/entity_effectors/effectors.go
new file mode 100644
index 0000000..488a5b1
--- /dev/null
+++ b/cli/api/entity_effectors/effectors.go
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package entity_effectors
+
+import (
+ "bytes"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+ "net/url"
+ "strconv"
+ "strings"
+)
+
+func EffectorList(network *net.Network, application, entity string) ([]models.EffectorSummary, error) {
+ path := fmt.Sprintf("/v1/applications/%s/entities/%s/effectors", application, entity)
+ var effectorList []models.EffectorSummary
+ body, err := network.SendGetRequest(path)
+ if err != nil {
+ return effectorList, err
+ }
+
+ err = json.Unmarshal(body, &effectorList)
+ return effectorList, err
+}
+
+func TriggerEffector(network *net.Network, application, entity, effector string, params []string, args []string) (string, error) {
+ if len(params) != len(args) {
+ return "", errors.New(strings.Join([]string{"Parameters not supplied:", strings.Join(params, ", ")}, " "))
+ }
+ path := fmt.Sprintf("/v1/applications/%s/entities/%s/effectors/%s", application, entity, effector)
+ data := url.Values{}
+ for i := range params {
+ data.Set(params[i], args[i])
+ }
+ req := network.NewPostRequest(path, bytes.NewBufferString(data.Encode()))
+ req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
+ req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))
+ body, err := network.SendRequest(req)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/entity_policies/policies.go
----------------------------------------------------------------------
diff --git a/cli/api/entity_policies/policies.go b/cli/api/entity_policies/policies.go
new file mode 100644
index 0000000..d776a05
--- /dev/null
+++ b/cli/api/entity_policies/policies.go
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package entity_policies
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+ "net/url"
+ "strconv"
+)
+
+// WIP
+func AddPolicy(network *net.Network, application, entity, policy string, config map[string]string) (models.PolicySummary, error) {
+ path := fmt.Sprintf("/v1/applications/%s/entities/%s/policies", application, entity)
+ data := url.Values{}
+ data.Set("policyType", policy)
+ //data.Add("config", config)
+ req := network.NewPostRequest(path, bytes.NewBufferString(data.Encode()))
+ req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
+ req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))
+ var policySummary models.PolicySummary
+ body, err := network.SendRequest(req)
+ if err != nil {
+ return policySummary, err
+ }
+ err = json.Unmarshal(body, &policySummary)
+ return policySummary, err
+}
+
+func PolicyList(network *net.Network, application, entity string) ([]models.PolicySummary, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/policies", application, entity)
+ var policyList []models.PolicySummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return policyList, err
+ }
+
+ err = json.Unmarshal(body, &policyList)
+ return policyList, err
+}
+
+func PolicyStatus(network *net.Network, application, entity, policy string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/policies/%s", application, entity, policy)
+ body, err := network.SendGetRequest(url)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func CurrentState(network *net.Network, application, entity string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/policies/current-state", application, entity)
+ body, err := network.SendGetRequest(url)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func StartPolicy(network *net.Network, application, entity, policy string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/policies/%s/start", application, entity, policy)
+ body, err := network.SendEmptyPostRequest(url)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func StopPolicy(network *net.Network, application, entity, policy string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/policies/%s/stop", application, entity, policy)
+ body, err := network.SendEmptyPostRequest(url)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func DestroyPolicy(network *net.Network, application, entity, policy string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/policies/%s/destroy", application, entity, policy)
+ body, err := network.SendEmptyPostRequest(url)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/entity_policy_config/config.go
----------------------------------------------------------------------
diff --git a/cli/api/entity_policy_config/config.go b/cli/api/entity_policy_config/config.go
new file mode 100644
index 0000000..0cf40fe
--- /dev/null
+++ b/cli/api/entity_policy_config/config.go
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package entity_policy_config
+
+import (
+ "encoding/json"
+ "fmt"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+)
+
+func CurrentState(network *net.Network, application, entity, policy string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/policies/%s/config/current-state", application, entity, policy)
+ body, err := network.SendGetRequest(url)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func GetConfigValue(network *net.Network, application, entity, policy, config string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/policies/%s/config/%s", application, entity, policy, config)
+ body, err := network.SendGetRequest(url)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+// WIP
+func SetConfigValue(network *net.Network, application, entity, policy, config string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/policies/%s/config/%s", application, entity, policy, config)
+ body, err := network.SendEmptyPostRequest(url)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func GetAllConfigValues(network *net.Network, application, entity, policy string) ([]models.PolicyConfigList, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/policies/%s/config", application, entity, policy)
+ var policyConfigList []models.PolicyConfigList
+ body, err := network.SendGetRequest(url)
+ if nil != err {
+ return policyConfigList, err
+ }
+ err = json.Unmarshal(body, &policyConfigList)
+ return policyConfigList, err
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/entity_sensors/sensors.go
----------------------------------------------------------------------
diff --git a/cli/api/entity_sensors/sensors.go b/cli/api/entity_sensors/sensors.go
new file mode 100644
index 0000000..ddb0d5b
--- /dev/null
+++ b/cli/api/entity_sensors/sensors.go
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package entity_sensors
+
+import (
+ "encoding/json"
+ "fmt"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+)
+
+func SensorValue(network *net.Network, application, entity, sensor string) (interface{}, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/sensors/%s", application, entity, sensor)
+ body, err := network.SendGetRequest(url)
+ if nil != err || 0 == len(body) {
+ return nil, err
+ }
+
+ var value interface{}
+ err = json.Unmarshal(body, &value)
+ if nil != err {
+ return nil, err
+ }
+
+ return value, nil
+}
+
+// WIP
+func DeleteSensor(network *net.Network, application, entity, sensor string) (string, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/sensors/%s", application, entity, sensor)
+ body, err := network.SendDeleteRequest(url)
+ if nil != err {
+ return "", err
+ }
+ return string(body), nil
+}
+
+// WIP
+//func SetSensor(network *net.Network, application, entity, sensor string) string {
+// url := fmt.Sprintf("/v1/applications/%s/entities/%s/sensors/%s", application, entity, sensor)
+// body, err := network.SendPostRequest(url)
+// if err != nil {
+// error_handler.ErrorExit(err)
+// }
+
+// return string(body)
+//}
+
+// WIP
+//func SetSensors(network *net.Network, application, entity, sensor string) string {
+// url := fmt.Sprintf("/v1/applications/%s/entities/%s/sensors", application, entity, sensor)
+// body, err := network.SendPostRequest(url)
+// if err != nil {
+// error_handler.ErrorExit(err)
+// }
+
+// return string(body)
+//}
+
+func SensorList(network *net.Network, application, entity string) ([]models.SensorSummary, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/sensors", application, entity)
+ body, err := network.SendGetRequest(url)
+ var sensorList []models.SensorSummary
+ if err != nil {
+ return sensorList, err
+ }
+
+ err = json.Unmarshal(body, &sensorList)
+ return sensorList, err
+}
+
+func CurrentState(network *net.Network, application, entity string) (map[string]interface{}, error) {
+ url := fmt.Sprintf("/v1/applications/%s/entities/%s/sensors/current-state", application, entity)
+ var currentState map[string]interface{}
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return currentState, err
+ }
+
+ err = json.Unmarshal(body, ¤tState)
+ return currentState, err
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/locations/locations.go
----------------------------------------------------------------------
diff --git a/cli/api/locations/locations.go b/cli/api/locations/locations.go
new file mode 100644
index 0000000..9bbb9b3
--- /dev/null
+++ b/cli/api/locations/locations.go
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package locations
+
+import (
+ "encoding/json"
+ "fmt"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+)
+
+func LocatedLocations(network *net.Network) (string, error) {
+ url := "/v1/locations/usage/LocatedLocations"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func GetLocation(network *net.Network, locationId string) (models.LocationSummary, error) {
+ url := fmt.Sprintf("/v1/locations/%s", locationId)
+ var locationDetail models.LocationSummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return locationDetail, err
+ }
+ err = json.Unmarshal(body, &locationDetail)
+ return locationDetail, err
+}
+
+func DeleteLocation(network *net.Network, locationId string) (string, error) {
+ url := fmt.Sprintf("/v1/locations/%s", locationId)
+ body, err := network.SendDeleteRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+// WIP
+func CreateLocation(network *net.Network, locationId string) (string, error) {
+ url := fmt.Sprintf("/v1/locations", locationId)
+ body, err := network.SendEmptyPostRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func LocationList(network *net.Network) ([]models.LocationSummary, error) {
+ url := "/v1/locations"
+ var locationList []models.LocationSummary
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return locationList, err
+ }
+
+ err = json.Unmarshal(body, &locationList)
+ return locationList, err
+}