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:38 UTC
[01/10] brooklyn-client git commit: move rest-client to
brooklyn-client
Repository: brooklyn-client
Updated Branches:
refs/heads/master a191255ee -> 8d0c3264e
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/release/license/files/LICENSE
----------------------------------------------------------------------
diff --git a/release/license/files/LICENSE b/release/license/files/LICENSE
deleted file mode 100644
index 9764158..0000000
--- a/release/license/files/LICENSE
+++ /dev/null
@@ -1,445 +0,0 @@
-
-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/release/license/source-inclusions.yaml
----------------------------------------------------------------------
diff --git a/release/license/source-inclusions.yaml b/release/license/source-inclusions.yaml
deleted file mode 100644
index dddc9dc..0000000
--- a/release/license/source-inclusions.yaml
+++ /dev/null
@@ -1,24 +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.
-#
-
-# extras file for org.heneveld.license-audit-maven-plugin
-# listing projects from which *source* files are included
-
-- id: github.com/urfave/cli
-- id: golang.org/x/crypto/ssh
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/scope/scope.go
----------------------------------------------------------------------
diff --git a/scope/scope.go b/scope/scope.go
deleted file mode 100644
index 9332c4a..0000000
--- a/scope/scope.go
+++ /dev/null
@@ -1,137 +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 scope
-
-import (
- "strings"
-)
-
-type Scope struct {
- Application string
- Entity string
- Effector string
- Config string
- Activity string
-}
-
-func (scope Scope) String() string {
- return strings.Join([]string{
- "{Application: ", scope.Application,
- ", Entity: ", scope.Entity,
- ", Effector: ", scope.Effector,
- ", Config: ", scope.Config,
- ", Activity: ", scope.Activity,
- "}",
- }, "")
-}
-
-func application(scope *Scope, id string) {
- scope.Application = id
-}
-
-func entity(scope *Scope, id string) {
- scope.Entity = id
-}
-
-func effector(scope *Scope, id string) {
- scope.Effector = id
-}
-
-func config(scope *Scope, id string) {
- scope.Config = id
-}
-
-func activity(scope *Scope, id string) {
- scope.Activity = id
-}
-
-var scopeSpecifier = map[string]func(scope *Scope, id string){
- "application": application,
- "app": application,
- "a": application,
- "entity": entity,
- "ent": entity,
- "e": entity,
- "effector": effector,
- "eff": effector,
- "f": effector,
- "config": config,
- "conf": config,
- "con": config,
- "c": config,
- "activity": activity,
- "act": activity,
- "v": activity,
-}
-
-// Scopes the arguments.
-// Assumes the arguments are a copy of the program args, including the first member that defines the program name.
-// Removes the scope arguments from the array and applies them to a scope object.
-// Returns the remaining arguments with the program name restored to first argument.
-// For example with input
-// br application 1 entity 2 doSomething
-// the function will return ([]string{"br", "doSomething"}, Scope{Application:1, Entity:2})
-func ScopeArguments(args []string) ([]string, Scope) {
- scope := Scope{}
-
- if len(args) < 2 {
- return args, scope
- }
-
- command := args[0]
- args = args[1:]
-
- args = defineScope(args, &scope)
-
- args = prepend(command, args)
-
- return args, scope
-}
-
-func defineScope(args []string, scope *Scope) []string {
-
- allScopesFound := false
- for !allScopesFound && len(args) > 2 && args[1][0] != '-' {
- if setAppropriateScope, nameOfAScope := scopeSpecifier[args[0]]; nameOfAScope {
- setAppropriateScope(scope, args[1])
- args = args[2:]
- } else {
- allScopesFound = true
- }
- }
-
- setDefaultEntityIfRequired(scope)
-
- return args
-}
-
-func setDefaultEntityIfRequired(scope *Scope) {
- if "" == scope.Entity {
- scope.Entity = scope.Application
- }
-}
-
-func prepend(v string, args []string) []string {
- result := make([]string, len(args)+1)
- result[0] = v
- for i, a := range args {
- result[i+1] = a
- }
- return result
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/terminal/table.go
----------------------------------------------------------------------
diff --git a/terminal/table.go b/terminal/table.go
deleted file mode 100644
index c163318..0000000
--- a/terminal/table.go
+++ /dev/null
@@ -1,102 +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 terminal
-
-import (
- "fmt"
- "strings"
- "unicode/utf8"
-)
-
-type Table interface {
- Add(row ...string)
- Print()
-}
-
-type PrintableTable struct {
- headers []string
- headerPrinted bool
- maxSizes []int
- rows [][]string
-}
-
-func NewTable(headers []string) Table {
- return &PrintableTable{
- headers: headers,
- maxSizes: make([]int, len(headers)),
- }
-}
-
-func (t *PrintableTable) Add(row ...string) {
- t.rows = append(t.rows, row)
-}
-
-func (t *PrintableTable) Print() {
- for _, row := range append(t.rows, t.headers) {
- t.calculateMaxSize(row)
- }
-
- if t.headerPrinted == false {
- t.printHeader()
- t.headerPrinted = true
- }
-
- for _, line := range t.rows {
- t.printRow(line)
- }
-
- t.rows = [][]string{}
-}
-
-func (t *PrintableTable) calculateMaxSize(row []string) {
- for index, value := range row {
- cellLength := utf8.RuneCountInString(value)
- if t.maxSizes[index] < cellLength {
- t.maxSizes[index] = cellLength
- }
- }
-}
-
-func (t *PrintableTable) printHeader() {
- output := ""
- for col, value := range t.headers {
- output = output + t.cellValue(col, value)
- }
- fmt.Println(output)
-}
-
-func (t *PrintableTable) printRow(row []string) {
- output := ""
- for columnIndex, value := range row {
- if columnIndex == 0 {
- value = value
- }
-
- output = output + t.cellValue(columnIndex, value)
- }
- fmt.Printf("%s\n", output)
-}
-
-func (t *PrintableTable) cellValue(col int, value string) string {
- padding := ""
- if col < len(t.headers)-1 {
- padding = strings.Repeat(" ", t.maxSizes[col]-utf8.RuneCountInString(value))
- }
- return fmt.Sprintf("%s%s ", value, padding)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/test/test.sh
----------------------------------------------------------------------
diff --git a/test/test.sh b/test/test.sh
deleted file mode 100644
index 7f86538..0000000
--- a/test/test.sh
+++ /dev/null
@@ -1,226 +0,0 @@
-#!/usr/bin/env bash
-# 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.
-
-declare -a FAILS
-
-export BRCLI_HOME=/tmp
-trap cleanup EXIT
-
-
-function usage() {
- echo "Usage: $0 <brooklyn_url> [ <user> <password> ]"
- exit 0
-}
-
-
-function cleanup() {
- rm -f $BRCLI_HOME/.brooklyn_cli
-}
-
-function title() {
- echo "*************************************************************************"
- echo " ${FUNCNAME[1]}"
- echo "*************************************************************************"
-}
-
-function fail() {
- local code=$?
- local message="$*"
- FAILS[${#FAILS[*]}]="${FUNCNAME[1]}: (${code}) ${message}"
-}
-
-function report() {
- if [ 0 -ne ${#FAILS[*]} ] ; then
- echo " ${#FAILS[*]} Test failures" 1>&2
- else
- echo All tests succeeded
- fi
- local n=0
- while [ $n -lt ${#FAILS[*]} ] ; do
- echo ${FAILS[$N]} 1>&2
- n=$(( $n + 1 ))
- done
-}
-
-
-function isAppStatus() {
- local appname=$1
- local status=$2
- br apps | grep "${appname}" | grep ${status} > /dev/null
-}
-
-function isEntityStatus() {
- local appname=$1
- local entity=$2
- local status=$3
-
- br app "${appname}" ent "${entity}" | grep ${status} > /dev/null
-}
-
-function waitForCommand() {
- local N=300 # 5 minutes
- while [ $N -gt 0 ] && ! "$@" ; do
- sleep 1
- N=$(($N - 1))
- done
- if [ $N -eq 0 ] ; then
- return 1
- fi
- return 0
-}
-
-
-
-function brIsDefined() {
- type br > /dev/null 2>&1
-}
-
-
-#
-# TESTS
-#
-
-function shouldLogin() {
- title
- br login $1 $2 $3 || fail
-}
-
-
-
-function shouldDeployTomcat() {
- title
-
- br deploy test_app.yaml
-
- waitForCommand isAppStatus "Test Tomcat" RUNNING || fail
-}
-
-function shouldRenameApp() {
- title
- local appname=$1
- local rename=$2
-
- br app "${appname}" rename "${rename}"
-
- br apps | grep "${rename}" | grep RUNNING || fail
-}
-
-function shouldGetAppConfig() {
- title
- local appname=$1
- br app "${appname}" config | grep brooklyn.wrapper_app | grep true || fail
-}
-
-function shouldGetTomcatServerEntity() {
- title
- local appname=$1
-
- br app "${appname}" entity | grep TomcatServer || fail
-}
-
-
-function shouldRenameTomcatServerEntity() {
- title
- local appname=$1
- local rename=$2
-
- br app "${appname}" entity "Tomcat Server" rename "${rename}"
- br app "${appname}" entity "${rename}" | grep TomcatServer || fail
-}
-
-function shouldStopEntity() {
- title
- local appname=$1
- local entityname=$2
-
- br app "${appname}" ent "${entityname}" stop
-
- waitForCommand isEntityStatus "${appname}" "${entityname}" STOPPED || fail; return
-}
-
-function shouldRestartEntity() {
- title
- local appname=$1
- local entityname=$2
-
- br app "${appname}" restart "${entityname}"
-
- waitForCommand isEntityStatus "${appname}" "${entityname}" RUNNING || fail; return
-}
-
-function shouldStartEntity() {
- title
- local appname=$1
- local entityname=$2
-
- br app "${appname}" start "${entityname}"
-
- waitForCommand isEntityStatus "${appname}" "${entityname}" RUNNING || fail; return
-}
-
-
-function runAllTests() {
-
- local brooklyn_url=${1}
- local user=${2}
- local password=${3}
-
- shouldLogin ${brooklyn_url} ${user} ${password}
- shouldDeployTomcat
- shouldRenameApp "Test Tomcat" mytest
- shouldGetAppConfig mytest
- shouldGetTomcatServerEntity mytest
- shouldRenameTomcatServerEntity mytest myserver
- shouldStopEntity mytest myserver
- shouldStartEntity mytest myserver
- shouldRestartEntity mytest myserver
-
-
- #... TODO add more tests here
-}
-
-#
-# main function
-#
-function main() {
-
- [ $1 ] || usage
-
- local brooklyn_url=${1}
- local user=${2}
- local password=${3}
-
- brIsDefined || {
- >&2 echo br is not defined
- exit 1
- }
-
- runAllTests ${brooklyn_url} ${user} ${password}
-
- # If there are test failures we leave the application running, in case it helps determine what failed.
- if [ 0 -eq ${#FAILS[*]} ] ; then
- echo Stopping test application
- br app mytest stop
- fi
-
- report
-
-}
-
-main $@
-exit ${#FAILS[*]}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/test/test_app.yaml
----------------------------------------------------------------------
diff --git a/test/test_app.yaml b/test/test_app.yaml
deleted file mode 100644
index f5e9abe..0000000
--- a/test/test_app.yaml
+++ /dev/null
@@ -1,22 +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.
-
-name: Test Tomcat
-location:
- replaceMeWithYourLocation
-services:
- - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
[09/10] brooklyn-client git commit: move rest-client to
brooklyn-client
Posted by an...@apache.org.
move rest-client to brooklyn-client
update brooklyn-client/cli/README.md
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-client/commit/4122cfe1
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-client/tree/4122cfe1
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-client/diff/4122cfe1
Branch: refs/heads/master
Commit: 4122cfe1183340e5417c3e02ad56388811184641
Parents: a191255
Author: Andrea Turli <an...@gmail.com>
Authored: Wed Sep 7 18:07:07 2016 +0200
Committer: Andrea Turli <an...@gmail.com>
Committed: Sat Sep 10 19:10:40 2016 +0200
----------------------------------------------------------------------
.gitignore | 5 +-
LICENSE | 445 ------------
NOTICE | 5 -
README.md | 118 ---
api/access_control/access_control.go | 48 --
api/activities/activities.go | 59 --
api/application/applications.go | 141 ----
api/catalog/catalog.go | 233 ------
api/entities/entities.go | 183 -----
api/entity_config/config.go | 94 ---
api/entity_effectors/effectors.go | 62 --
api/entity_policies/policies.go | 104 ---
api/entity_policy_config/config.go | 65 --
api/entity_sensors/sensors.go | 98 ---
api/locations/locations.go | 77 --
api/server/server.go | 190 -----
api/usage/usage.go | 62 --
api/version/version.go | 36 -
app/app.go | 170 -----
br/brooklyn.go | 65 --
build.xml | 59 --
cli/LICENSE | 445 ++++++++++++
cli/NOTICE | 5 +
cli/README.md | 118 +++
cli/api/access_control/access_control.go | 48 ++
cli/api/activities/activities.go | 59 ++
cli/api/application/applications.go | 141 ++++
cli/api/catalog/catalog.go | 233 ++++++
cli/api/entities/entities.go | 183 +++++
cli/api/entity_config/config.go | 94 +++
cli/api/entity_effectors/effectors.go | 62 ++
cli/api/entity_policies/policies.go | 104 +++
cli/api/entity_policy_config/config.go | 65 ++
cli/api/entity_sensors/sensors.go | 98 +++
cli/api/locations/locations.go | 77 ++
cli/api/server/server.go | 190 +++++
cli/api/usage/usage.go | 62 ++
cli/api/version/version.go | 36 +
cli/app/app.go | 170 +++++
cli/br/brooklyn.go | 65 ++
cli/build.xml | 59 ++
cli/command/command.go | 30 +
cli/command/supercommand.go | 30 +
cli/command_factory/factory.go | 141 ++++
cli/command_metadata/command_metadata.go | 33 +
cli/command_runner/runner.go | 61 ++
cli/commands/access.go | 59 ++
cli/commands/activity-stream.go | 149 ++++
cli/commands/activity.go | 162 +++++
cli/commands/add-catalog.go | 59 ++
cli/commands/add-children.go | 63 ++
cli/commands/add-location.go | 33 +
cli/commands/add-policy.go | 50 ++
cli/commands/application.go | 111 +++
cli/commands/catalog-applications.go | 33 +
cli/commands/catalog-entities.go | 33 +
cli/commands/catalog-entity.go | 33 +
cli/commands/catalog-location.go | 33 +
cli/commands/catalog-locations.go | 33 +
cli/commands/catalog-policies.go | 33 +
cli/commands/catalog-policy.go | 33 +
cli/commands/catalog.go | 63 ++
cli/commands/config.go | 78 ++
cli/commands/delete-catalog-application.go | 33 +
cli/commands/delete-catalog-entity.go | 33 +
cli/commands/delete-catalog-policy.go | 33 +
cli/commands/delete.go | 59 ++
cli/commands/deploy.go | 85 +++
cli/commands/destroy-policy.go | 59 ++
cli/commands/effector.go | 70 ++
cli/commands/entity.go | 127 ++++
cli/commands/invoke.go | 203 ++++++
cli/commands/list.go | 90 +++
cli/commands/locations.go | 63 ++
cli/commands/login.go | 113 +++
cli/commands/policy.go | 114 +++
cli/commands/rename.go | 59 ++
cli/commands/reset-catalog.go | 33 +
cli/commands/sensor.go | 118 +++
cli/commands/set.go | 59 ++
cli/commands/spec.go | 59 ++
cli/commands/start-policy.go | 59 ++
cli/commands/stop-policy.go | 59 ++
cli/commands/tree.go | 78 ++
cli/commands/utils.go | 38 +
cli/commands/version.go | 59 ++
cli/error_handler/error.go | 46 ++
cli/glide.lock | 10 +
cli/glide.yaml | 6 +
cli/io/config.go | 72 ++
cli/models/access.go | 24 +
cli/models/applications.go | 97 +++
cli/models/catalog.go | 63 ++
cli/models/config.go | 31 +
cli/models/effectors.go | 34 +
cli/models/entities.go | 27 +
cli/models/locations.go | 28 +
cli/models/policies.go | 39 +
cli/models/sensors.go | 26 +
cli/models/version.go | 34 +
cli/net/net.go | 211 ++++++
cli/pom.xml | 132 ++++
cli/release/assembly.xml | 43 ++
cli/release/build.bat | 24 +
cli/release/build.sh | 283 ++++++++
cli/release/files/README | 42 ++
cli/release/license/files/LICENSE | 445 ++++++++++++
cli/release/license/source-inclusions.yaml | 24 +
cli/scope/scope.go | 137 ++++
cli/terminal/table.go | 102 +++
cli/test/test.sh | 226 ++++++
cli/test/test_app.yaml | 22 +
command/command.go | 30 -
command/supercommand.go | 30 -
command_factory/factory.go | 141 ----
command_metadata/command_metadata.go | 33 -
command_runner/runner.go | 61 --
commands/access.go | 59 --
commands/activity-stream.go | 149 ----
commands/activity.go | 162 -----
commands/add-catalog.go | 59 --
commands/add-children.go | 63 --
commands/add-location.go | 33 -
commands/add-policy.go | 50 --
commands/application.go | 111 ---
commands/catalog-applications.go | 33 -
commands/catalog-entities.go | 33 -
commands/catalog-entity.go | 33 -
commands/catalog-location.go | 33 -
commands/catalog-locations.go | 33 -
commands/catalog-policies.go | 33 -
commands/catalog-policy.go | 33 -
commands/catalog.go | 63 --
commands/config.go | 78 --
commands/delete-catalog-application.go | 33 -
commands/delete-catalog-entity.go | 33 -
commands/delete-catalog-policy.go | 33 -
commands/delete.go | 59 --
commands/deploy.go | 85 ---
commands/destroy-policy.go | 59 --
commands/effector.go | 70 --
commands/entity.go | 127 ----
commands/invoke.go | 203 ------
commands/list.go | 90 ---
commands/locations.go | 63 --
commands/login.go | 113 ---
commands/policy.go | 114 ---
commands/rename.go | 59 --
commands/reset-catalog.go | 33 -
commands/sensor.go | 118 ---
commands/set.go | 59 --
commands/spec.go | 59 --
commands/start-policy.go | 59 --
commands/stop-policy.go | 59 --
commands/tree.go | 78 --
commands/utils.go | 38 -
commands/version.go | 59 --
error_handler/error.go | 46 --
glide.lock | 10 -
glide.yaml | 6 -
io/config.go | 72 --
java/pom.xml | 719 +++++++++++++++++++
.../brooklyn/rest/client/BrooklynApi.java | 419 +++++++++++
.../brooklyn/rest/client/BrooklynApiUtil.java | 154 ++++
.../util/http/BuiltResponsePreservingError.java | 79 ++
.../ApplicationResourceIntegrationTest.java | 190 +++++
.../rest/client/BrooklynApiRestClientTest.java | 163 +++++
.../rest/client/BrooklynApiUtilTest.java | 129 ++++
.../src/test/resources/catalog/test-catalog.bom | 33 +
java/src/test/webapp/WEB-INF/web.xml | 129 ++++
models/access.go | 24 -
models/applications.go | 97 ---
models/catalog.go | 63 --
models/config.go | 31 -
models/effectors.go | 34 -
models/entities.go | 27 -
models/locations.go | 28 -
models/policies.go | 39 -
models/sensors.go | 26 -
models/version.go | 34 -
net/net.go | 211 ------
pom.xml | 538 +++++++++++---
release/assembly.xml | 43 --
release/build.bat | 24 -
release/build.sh | 283 --------
release/files/README | 42 --
release/license/files/LICENSE | 445 ------------
release/license/source-inclusions.yaml | 24 -
scope/scope.go | 137 ----
terminal/table.go | 102 ---
test/test.sh | 226 ------
test/test_app.yaml | 22 -
192 files changed, 10064 insertions(+), 7558 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 08d4901..6dacd7f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,4 +8,7 @@ target
.classpath
.settings/
.metadata/
-vendor/
\ No newline at end of file
+vendor/
+
+*.log
+brooklyn*.log.*
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 9764158..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,445 +0,0 @@
-
-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/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index 6d1f608..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-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/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
deleted file mode 100644
index e45eacb..0000000
--- a/README.md
+++ /dev/null
@@ -1,118 +0,0 @@
-
-# [![**Brooklyn**](https://brooklyn.apache.org/style/img/apache-brooklyn-logo-244px-wide.png)](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 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, 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/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
-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/api/access_control/access_control.go
----------------------------------------------------------------------
diff --git a/api/access_control/access_control.go b/api/access_control/access_control.go
deleted file mode 100644
index c68eecf..0000000
--- a/api/access_control/access_control.go
+++ /dev/null
@@ -1,48 +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 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/api/activities/activities.go
----------------------------------------------------------------------
diff --git a/api/activities/activities.go b/api/activities/activities.go
deleted file mode 100644
index 0364dcb..0000000
--- a/api/activities/activities.go
+++ /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.
- */
-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/api/application/applications.go
----------------------------------------------------------------------
diff --git a/api/application/applications.go b/api/application/applications.go
deleted file mode 100644
index f46ebac..0000000
--- a/api/application/applications.go
+++ /dev/null
@@ -1,141 +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 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/api/catalog/catalog.go
----------------------------------------------------------------------
diff --git a/api/catalog/catalog.go b/api/catalog/catalog.go
deleted file mode 100644
index dd5b75a..0000000
--- a/api/catalog/catalog.go
+++ /dev/null
@@ -1,233 +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 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/api/entities/entities.go
----------------------------------------------------------------------
diff --git a/api/entities/entities.go b/api/entities/entities.go
deleted file mode 100644
index 90dbb49..0000000
--- a/api/entities/entities.go
+++ /dev/null
@@ -1,183 +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 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/api/entity_config/config.go
----------------------------------------------------------------------
diff --git a/api/entity_config/config.go b/api/entity_config/config.go
deleted file mode 100644
index 66cd1d5..0000000
--- a/api/entity_config/config.go
+++ /dev/null
@@ -1,94 +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 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/api/entity_effectors/effectors.go
----------------------------------------------------------------------
diff --git a/api/entity_effectors/effectors.go b/api/entity_effectors/effectors.go
deleted file mode 100644
index 488a5b1..0000000
--- a/api/entity_effectors/effectors.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 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/api/entity_policies/policies.go
----------------------------------------------------------------------
diff --git a/api/entity_policies/policies.go b/api/entity_policies/policies.go
deleted file mode 100644
index d776a05..0000000
--- a/api/entity_policies/policies.go
+++ /dev/null
@@ -1,104 +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 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/api/entity_policy_config/config.go
----------------------------------------------------------------------
diff --git a/api/entity_policy_config/config.go b/api/entity_policy_config/config.go
deleted file mode 100644
index 0cf40fe..0000000
--- a/api/entity_policy_config/config.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 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/api/entity_sensors/sensors.go
----------------------------------------------------------------------
diff --git a/api/entity_sensors/sensors.go b/api/entity_sensors/sensors.go
deleted file mode 100644
index ddb0d5b..0000000
--- a/api/entity_sensors/sensors.go
+++ /dev/null
@@ -1,98 +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 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/api/locations/locations.go
----------------------------------------------------------------------
diff --git a/api/locations/locations.go b/api/locations/locations.go
deleted file mode 100644
index 9bbb9b3..0000000
--- a/api/locations/locations.go
+++ /dev/null
@@ -1,77 +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 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
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/api/server/server.go
----------------------------------------------------------------------
diff --git a/api/server/server.go b/api/server/server.go
deleted file mode 100644
index a46b705..0000000
--- a/api/server/server.go
+++ /dev/null
@@ -1,190 +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 server
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/net"
-)
-
-func Up(network *net.Network) (string, error) {
- url := "/v1/server/up"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func Version(network *net.Network) (string, error) {
- url := "/v1/server/version"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func GetConfig(network *net.Network, configKey string) (string, error) {
- url := fmt.Sprintf("/v1/server/config/%s", configKey)
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func Reload(network *net.Network) (string, error) {
- url := "/v1/server/properties/reload"
- body, err := network.SendEmptyPostRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func Status(network *net.Network) (string, error) {
- url := "/v1/server/status"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func User(network *net.Network) (string, error) {
- url := "/v1/server/user"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func ShuttingDown(network *net.Network) (string, error) {
- url := "/v1/server/shuttingDown"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func Healthy(network *net.Network) (string, error) {
- url := "/v1/server/healthy"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func UpExtended(network *net.Network) (string, error) {
- url := "/v1/server/up/extended"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func State(network *net.Network) (string, error) {
- url := "/v1/server/ha/state"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-// WIP
-func SetState(network *net.Network) (string, error) {
- url := "/v1/server/ha/state"
- body, err := network.SendEmptyPostRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func Metrics(network *net.Network) (string, error) {
- url := "/v1/server/ha/metrics"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func Priority(network *net.Network) (string, error) {
- url := "/v1/server/ha/priority"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-// WIP
-func SetPriority(network *net.Network) (string, error) {
- url := "/v1/server/ha/priority"
- body, err := network.SendEmptyPostRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
-
-func States(network *net.Network) (string, error) {
- url := "/v1/server/ha/states"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", nil
- }
- return string(body)
-}
-
-// WIP
-func ClearStates(network *net.Network) (string, error) {
- url := "/v1/server/ha/states/clear"
- body, err := network.SendEmptyPostRequest(url)
- if err != nil {
- return "", nil
- }
- return string(body), nil
-}
-
-func Export(network *net.Network) (string, error) {
- url := "/v1/server/ha/persist/export"
- body, err := network.SendGetRequest(url)
- if err != nil {
- return "", nil
- }
- return string(body), nil
-}
-
-// WIP
-func Shutdown(network *net.Network) (string, error) {
- url := "/v1/server/shutdown"
- body, err := network.SendEmptyPostRequest(url)
- if err != nil {
- return "", err
- }
- return string(body), nil
-}
[08/10] brooklyn-client git commit: move rest-client to
brooklyn-client
Posted by an...@apache.org.
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 @@
+
+# [![**Brooklyn**](https://brooklyn.apache.org/style/img/apache-brooklyn-logo-244px-wide.png)](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
+}
[02/10] brooklyn-client git commit: move rest-client to
brooklyn-client
Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/test/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/java/src/test/webapp/WEB-INF/web.xml b/java/src/test/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..38b637a
--- /dev/null
+++ b/java/src/test/webapp/WEB-INF/web.xml
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd" >
+
+<web-app>
+ <display-name>Brooklyn REST API v1</display-name>
+
+ <filter>
+ <filter-name>Brooklyn Request Tagging Filter</filter-name>
+ <filter-class>org.apache.brooklyn.rest.filter.RequestTaggingFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>Brooklyn Request Tagging Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <filter>
+ <filter-name>Brooklyn Properties Authentication Filter</filter-name>
+ <filter-class>org.apache.brooklyn.rest.filter.BrooklynPropertiesSecurityFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>Brooklyn Properties Authentication Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <filter>
+ <filter-name>Brooklyn Logging Filter</filter-name>
+ <filter-class>org.apache.brooklyn.rest.filter.LoggingFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>Brooklyn Logging Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <filter>
+ <filter-name>Brooklyn HA Master Filter</filter-name>
+ <filter-class>org.apache.brooklyn.rest.filter.HaMasterCheckFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>Brooklyn HA Master Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+<!-- Brooklyn REST is usually run as a filter so static content can be placed in a webapp
+ to which this is added; to run as a servlet directly, replace the filter tags
+ below (after the comment) with the servlet tags (commented out immediately below),
+ (and do the same for the matching tags at the bottom)
+ <servlet>
+ <servlet-name>Brooklyn REST API v1 Servlet</servlet-name>
+ <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+ -->
+ <filter>
+ <filter-name>Brooklyn REST API v1 Filter</filter-name>
+ <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
+
+ <!-- load our REST API jersey resources explicitly
+ (the package scanner will only pick up classes with @Path annotations - doesn't look at implemented interfaces)
+ -->
+ <init-param>
+ <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
+ <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
+ </init-param>
+ <init-param>
+ <param-name>com.sun.jersey.config.property.classnames</param-name>
+ <param-value>
+ org.apache.brooklyn.rest.apidoc.ApidocHelpMessageBodyWriter;
+ org.apache.brooklyn.rest.util.FormMapProvider;
+ com.fasterxml.jackson.jaxrs.JacksonJsonProvider;
+ org.apache.brooklyn.rest.resources.ActivityResource;
+ org.apache.brooklyn.rest.resources.ApidocResource;
+ org.apache.brooklyn.rest.resources.ApplicationResource;
+ org.apache.brooklyn.rest.resources.CatalogResource;
+ org.apache.brooklyn.rest.resources.EffectorResource;
+ org.apache.brooklyn.rest.resources.EntityConfigResource;
+ org.apache.brooklyn.rest.resources.EntityResource;
+ org.apache.brooklyn.rest.resources.LocationResource;
+ org.apache.brooklyn.rest.resources.PolicyConfigResource;
+ org.apache.brooklyn.rest.resources.PolicyResource;
+ org.apache.brooklyn.rest.resources.ScriptResource;
+ org.apache.brooklyn.rest.resources.SensorResource;
+ org.apache.brooklyn.rest.resources.VersionResource;
+ </param-value>
+ </init-param>
+
+ <init-param>
+ <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
+ <param-value>true</param-value>
+ </init-param>
+
+ <!-- no need for WADL. of course you can turn it back on it you want. -->
+ <init-param>
+ <param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
+ <param-value>true</param-value>
+ </init-param>
+
+ </filter>
+ <filter-mapping>
+ <filter-name>Brooklyn REST API v1 Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+<!-- Brooklyn REST as a filter above; replace above 5 lines with those commented out below,
+ to run it as a servlet (see note above)
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Brooklyn REST API v1 Servlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+-->
+</web-app>
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/models/access.go
----------------------------------------------------------------------
diff --git a/models/access.go b/models/access.go
deleted file mode 100644
index 7fbdcbf..0000000
--- a/models/access.go
+++ /dev/null
@@ -1,24 +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 models
-
-type AccessSummary struct {
- Links map[string]URI `json:"links"`
- LocationProvisioningAllowed bool `json:"locationProvisioningAllowed"`
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/models/applications.go
----------------------------------------------------------------------
diff --git a/models/applications.go b/models/applications.go
deleted file mode 100644
index aa44b8d..0000000
--- a/models/applications.go
+++ /dev/null
@@ -1,97 +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 models
-
-type Tree struct {
- Id string `json:"id"`
- ParentId string `json:"parentId"`
- Name string `json:"name"`
- Type string `json:"type"`
- CatalogItemId string `json:"catalogItemId"`
- Children []Tree `json:"children"`
- GroupIds []string `json:"groupIds"`
- Members []string `json:"members"`
-}
-
-type TaskSummary struct {
- SubmitTimeUtc int64 `json:"submitTimeUtc"`
- EndTimeUtc int64 `json:"endTimeUtc"`
- IsCancelled bool `json:"isCancelled"`
- CurrentStatus string `json:"currentStatus"`
- BlockingTask LinkTaskWithMetadata `json:"blockingTask"`
- DisplayName string `json:"displayName"`
- Streams map[string]LinkStreamsWithMetadata `json:"streams"`
- Description string `json:"description"`
- EntityId string `json:"entityId"`
- EntityDisplayName string `json:"entityDisplayName"`
- Error bool `json:"error"`
- SubmittedByTask LinkTaskWithMetadata `json:"submittedByTask"`
- Result interface{} `json:"result"`
- IsError bool `json:"isError"`
- DetailedStatus string `json:"detailedStatus"`
- Children []LinkTaskWithMetadata `json:"children"`
- BlockingDetails string `json:"blockingDetails"`
- Cancelled bool `json:"cancelled"`
- Links map[string]URI `json:"links"`
- Id string `json:"id"`
- StartTimeUtc int64 `json:"startTimeUtc"`
-}
-
-type ApplicationSummary struct {
- Links map[string]URI `json:"links"`
- Id string `json:"id"`
- Spec ApplicationSpec `json:"spec"`
- Status Status `json:"status"`
-}
-
-type ApplicationSpec struct {
- Name string `json:"name"`
- Type string `json:"type"`
- Locations []string `json:"locations"`
-}
-
-type Status string
-
-type LinkWithMetadata struct {
-}
-
-type LinkStreamsWithMetadata struct {
- Link string `json:"link"`
- Metadata LinkStreamMetadata `json:"metadata"`
-}
-
-type LinkStreamMetadata struct {
- Name string `json:"name"`
- Size int64 `json:"size"`
- SizeText string `json:"sizeText"`
-}
-
-type LinkTaskWithMetadata struct {
- Link string `json:"link"`
- Metadata LinkTaskMetadata `json:"metadata"`
-}
-
-type LinkTaskMetadata struct {
- Id string `json:"id"`
- TaskName string `json:"taskName"`
- EntityId string `json:"entityId"`
- EntityDisplayName string `json:"entityDisplayName"`
-}
-
-type URI string
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/models/catalog.go
----------------------------------------------------------------------
diff --git a/models/catalog.go b/models/catalog.go
deleted file mode 100644
index ef6dabf..0000000
--- a/models/catalog.go
+++ /dev/null
@@ -1,63 +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 models
-
-type CatalogItemSummary struct {
- Name string `json:"name"`
- JavaType string `json:"javaType"`
- SymbolicName string `json:"symbolicName"`
- Version string `json:"version"`
- PlanYaml string `json:"planYaml"`
- Description string `json:"description"`
- Deprecated bool `json:"deprecated"`
- Links map[string]interface{} `json:"links"`
- Id string `json:"id"`
- Type string `json:"type"`
-}
-
-type CatalogPolicySummary struct {
- symbolicName string `json:"symbolicName"`
- version string `json:"version"`
- displayName string `json:"name"`
- javaType string `json:"javaType"`
- planYaml string `json:"planYaml"`
- description string `json:"description"`
- iconUrl string `json:"iconUrl"`
- deprecated bool `json:"deprecated"`
- links map[string]URI `json:"links"`
-}
-
-type CatalogLocationSummary struct {
-}
-
-type CatalogEntitySummary struct {
- symbolicName string `json:"symbolicName"`
- version string `json:"version"`
- displayName string `json:"name"`
- javaType string `json:"javaType"`
- planYaml string `json:"planYaml"`
- description string `json:"description"`
- Config []ConfigSummary `json:"config"`
- Effectors []EffectorSummary `json:"effectors"`
- Sensors []SensorSummary `json:"sensors"`
- Deprecated bool `json:"deprecated"`
- Links map[string]interface{} `json:"links"`
- Id string `json:"id"`
- Type string `json:"type"`
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/models/config.go
----------------------------------------------------------------------
diff --git a/models/config.go b/models/config.go
deleted file mode 100644
index bc97650..0000000
--- a/models/config.go
+++ /dev/null
@@ -1,31 +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 models
-
-type ConfigSummary struct {
- Reconfigurable bool `json:"reconfigurable"`
- PossibleValues []map[string]string `json:"possibleValues"`
- DefaultValue interface{} `json:"defaultValue"`
- Name string `json:"name"`
- Description string `json:"description"`
- Links map[string]URI `json:"links"`
- Label string `json:"label"`
- Priority float64 `json:"priority"`
- Type string `json:"type"`
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/models/effectors.go
----------------------------------------------------------------------
diff --git a/models/effectors.go b/models/effectors.go
deleted file mode 100644
index 1b846b7..0000000
--- a/models/effectors.go
+++ /dev/null
@@ -1,34 +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 models
-
-type EffectorSummary struct {
- Name string `json:"name"`
- Description string `json:"description"`
- Links map[string]URI `json:"links"`
- Parameters []ParameterSummary `json:"parameters"`
- ReturnType string `json:"returnType"`
-}
-
-type ParameterSummary struct {
- Name string `json:"name"`
- Type string `json:"type"`
- Description string `json:"description"`
- DefaultValue interface{} `json:"defaultValue"`
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/models/entities.go
----------------------------------------------------------------------
diff --git a/models/entities.go b/models/entities.go
deleted file mode 100644
index fdb85dc..0000000
--- a/models/entities.go
+++ /dev/null
@@ -1,27 +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 models
-
-type EntitySummary struct {
- CatalogItemId string `json:"catalogItemId"`
- Name string `json:"name"`
- Links map[string]URI `json:"links"`
- Id string `json:"id"`
- Type string `json:"type"`
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/models/locations.go
----------------------------------------------------------------------
diff --git a/models/locations.go b/models/locations.go
deleted file mode 100644
index 2505eae..0000000
--- a/models/locations.go
+++ /dev/null
@@ -1,28 +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 models
-
-type LocationSummary struct {
- Id string `json:"id"`
- Name string `json:"name"`
- Spec string `json:"spec"`
- Type string `json:"type"`
- Config map[string]interface{} `json:"config"`
- Links map[string]URI `json:"links"`
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/models/policies.go
----------------------------------------------------------------------
diff --git a/models/policies.go b/models/policies.go
deleted file mode 100644
index fca9298..0000000
--- a/models/policies.go
+++ /dev/null
@@ -1,39 +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 models
-
-type PolicySummary struct {
- CatalogItemId string `json:"catalogItemId"`
- Name string `json:"name"`
- Links map[string]URI `json:"links"`
- Id string `json:"id"`
- State Status `json:"state"`
-}
-
-type PolicyConfigList struct {
- Name string `json:"name"`
- Type string `json:"type"`
- DefaultValue interface{} `json:"defaultValue`
- Description string `json:"description"`
- Reconfigurable bool `json:"reconfigurable"`
- Label string `json:"label"`
- Priority int64 `json:"priority"`
- PossibleValues []interface{} `json:"possibleValues"`
- Links map[string]URI `json:"links"`
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/models/sensors.go
----------------------------------------------------------------------
diff --git a/models/sensors.go b/models/sensors.go
deleted file mode 100644
index 67b3b4f..0000000
--- a/models/sensors.go
+++ /dev/null
@@ -1,26 +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 models
-
-type SensorSummary struct {
- Name string `json:"name"`
- Description string `json:"description"`
- Links map[string]URI `json:"links"`
- Type string `json:"type"`
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/models/version.go
----------------------------------------------------------------------
diff --git a/models/version.go b/models/version.go
deleted file mode 100644
index 8f12a67..0000000
--- a/models/version.go
+++ /dev/null
@@ -1,34 +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 models
-
-type VersionSummary struct {
- Version string `json:"version"`
- BuildSha1 string `json:"buildSha1"`
- BuildBranch string `json:"buildBranch"`
- Features []BrooklynFeatureSummary `json:"features"`
-}
-
-type BrooklynFeatureSummary struct {
- Name string `json:"name"`
- SymbolicName string `json:"symbolicName"`
- Version string `json:"version"`
- LastModified string `json:"lastModified"`
- AdditionalData map[string]string `json:"additionalData"`
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/net/net.go
----------------------------------------------------------------------
diff --git a/net/net.go b/net/net.go
deleted file mode 100644
index b35a6c3..0000000
--- a/net/net.go
+++ /dev/null
@@ -1,211 +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 net
-
-import (
- "bytes"
- "encoding/json"
- "errors"
- "io"
- "io/ioutil"
- "net/http"
- "net/url"
- "os"
- "path/filepath"
- "strconv"
- "strings"
- "crypto/tls"
-)
-
-type Network struct {
- BrooklynUrl string
- BrooklynUser string
- BrooklynPass string
- SkipSslChecks bool
-}
-
-func NewNetwork(brooklynUrl, brooklynUser, brooklynPass string, skipSslChecks bool) (net *Network) {
- net = new(Network)
- net.BrooklynUrl = brooklynUrl
- net.BrooklynUser = brooklynUser
- net.BrooklynPass = brooklynPass
- net.SkipSslChecks = skipSslChecks
- return
-}
-
-func (net *Network) NewRequest(method, path string, body io.Reader) *http.Request {
- req, _ := http.NewRequest(method, net.BrooklynUrl+path, body)
- req.SetBasicAuth(net.BrooklynUser, net.BrooklynPass)
- return req
-}
-
-func (net *Network) NewGetRequest(url string) *http.Request {
- return net.NewRequest("GET", url, nil)
-}
-
-func (net *Network) NewPostRequest(url string, body io.Reader) *http.Request {
- return net.NewRequest("POST", url, body)
-}
-
-func (net *Network) NewDeleteRequest(url string) *http.Request {
- return net.NewRequest("DELETE", url, nil)
-}
-
-type HttpError struct {
- Code int
- Status string
- Headers http.Header
- Body string
-}
-
-func (err HttpError) Error() string {
- return err.Status
-}
-
-func makeError(resp *http.Response, code int, body []byte) error {
- theError := HttpError{
- Code: code,
- Status: resp.Status,
- Headers: resp.Header,
- }
- details := make(map[string]string)
- if err := json.Unmarshal(body, &details); nil == err {
- if message, ok := details["message"]; ok {
- theError.Body = message
- return theError
- }
- }
- theError.Body = string(body)
- return theError
-}
-
-func (net *Network) SendRequest(req *http.Request) ([]byte, error) {
- tr := &http.Transport{
- TLSClientConfig: &tls.Config{InsecureSkipVerify: net.SkipSslChecks},
- }
- client := &http.Client{Transport: tr}
- resp, err := client.Do(req)
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
- body, err := ioutil.ReadAll(resp.Body)
- if code, failed := unsuccessful(resp.Status); failed {
- return nil, makeError(resp, code, body)
- }
- return body, err
-}
-
-const httpSuccessSeriesFrom = 200
-const httpSuccessSeriesTo = 300
-
-func unsuccessful(status string) (int, bool) {
- tokens := strings.Split(status, " ")
- if 0 == len(tokens) {
- return -1, false
- }
- code, err := strconv.Atoi(tokens[0])
- if nil != err {
- return -1, false
- }
- return code, code < httpSuccessSeriesFrom || httpSuccessSeriesTo <= code
-}
-
-func (net *Network) SendGetRequest(url string) ([]byte, error) {
- req := net.NewGetRequest(url)
- req.Header.Set("Accept", "application/json, text/plain")
- body, err := net.SendRequest(req)
- return body, err
-}
-
-func (net *Network) SendDeleteRequest(url string) ([]byte, error) {
- req := net.NewDeleteRequest(url)
- body, err := net.SendRequest(req)
- return body, err
-}
-
-func (net *Network) SendEmptyPostRequest(url string) ([]byte, error) {
- req := net.NewPostRequest(url, nil)
- body, err := net.SendRequest(req)
- return body, err
-}
-
-func (net *Network) SendPostRequest(urlStr string, data []byte) ([]byte, error) {
- req := net.NewPostRequest(urlStr, bytes.NewBuffer(data))
- req.Header.Set("Content-Type", "application/json")
- body, err := net.SendRequest(req)
- return body, err
-}
-
-func (net *Network) SendPostResourceRequest(restUrl string, resourceUrl string, contentType string) ([]byte, error) {
- resource, err := openResource(resourceUrl)
- defer resource.Close()
- req := net.NewPostRequest(restUrl, resource)
- req.Header.Set("Content-Type", contentType)
- body, err := net.SendRequest(req)
- return body, err
-}
-
-func openResource(resourceUrl string) (io.ReadCloser, error) {
- u, err := url.Parse(resourceUrl)
- if err != nil {
- return nil, err
- }
- if "" == u.Scheme || "file" == u.Scheme {
- return openFileResource(u)
-
- } else if "http" == u.Scheme || "https" == u.Scheme {
- return openHttpResource(resourceUrl)
-
- } else {
- return nil, errors.New("Unrecognised protocol scheme: " + u.Scheme)
- }
-}
-
-func openFileResource(url *url.URL) (io.ReadCloser, error) {
- filePath := url.Path;
- file, err := os.Open(filepath.Clean(filePath))
- if err != nil {
- return nil, err
- }
- return file, nil
-}
-
-func openHttpResource(resourceUrl string) (io.ReadCloser, error) {
- resp, err := http.Get(resourceUrl)
- if err != nil {
- return nil, err
- }
- return resp.Body, nil
-}
-
-
-func VerifyLoginURL(network *Network) error {
- url, err := url.Parse(network.BrooklynUrl)
- if err != nil {
- return err
- }
- if url.Scheme != "http" && url.Scheme != "https" {
- return errors.New("Use login command to set Brooklyn URL with a scheme of \"http\" or \"https\"")
- }
- if url.Host == "" {
- return errors.New("Use login command to set Brooklyn URL with a valid host[:port]")
- }
- return nil
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 866ca04..292f835 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,116 +17,472 @@
specific language governing permissions and limitations
under the License.
-->
-<project
- xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-parent</artifactId>
- <version>0.10.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
- <relativePath>../brooklyn-server/parent/</relativePath>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>17</version>
+ <relativePath></relativePath> <!-- prevent loading of ../pom.xml as the "parent" -->
</parent>
-
+
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-client</artifactId>
+ <version>0.10.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
<packaging>pom</packaging>
- <artifactId>brooklyn-client-cli</artifactId>
- <name>Brooklyn Client Command Line Interface</name>
+ <name>Brooklyn Client</name>
<description>
- A command line client for Apache Brooklyn
+ Brooklyn Client project root, serving as the ancestor POM for all projects --
+ declaring versions, profiles, and the modules to build
</description>
+ <scm>
+ <connection>scm:git:https://git-wip-us.apache.org/repos/asf/incubator-brooklyn.git</connection>
+ <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/brooklyn.git</developerConnection>
+ <url>https://git-wip-us.apache.org/repos/asf?p=incubator-brooklyn.git</url>
+ <tag>HEAD</tag>
+ </scm>
- <!--
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://issues.apache.org/jira/browse/BROOKLYN</url>
+ </issueManagement>
+ <ciManagement>
+ <system>Jenkins</system>
+ <url>https://builds.apache.org/job/incubator-brooklyn-master-build/</url>
+ </ciManagement>
+ <mailingLists>
+ <mailingList>
+ <name>Brooklyn Developer List</name>
+ <subscribe>dev-subscribe@brooklyn.apache.org</subscribe>
+ <unsubscribe>dev-unsubscribe@brooklyn.apache.org</unsubscribe>
+ <post>dev@brooklyn.apache.org</post>
+ <archive>
+ http://mail-archives.apache.org/mod_mbox/brooklyn-dev/
+ </archive>
+ </mailingList>
+ </mailingLists>
- Run as one of:
+ <properties>
+ <brooklyn.version>0.10.0-SNAPSHOT</brooklyn.version> <!-- BROOKLYN_VERSION -->
- mvn -Dtarget=native clean install build for local platform
- mvn -Dtarget=all clean install build for all supported platforms
- mvn -Dtarget=cross -Dos=OS -Darch=ARCH clean install build for platform with operating system OS and architecture ARCH
+ <org.osgi.core.version>6.0.0</org.osgi.core.version>
- -->
+ <!-- Compilation -->
+ <java.version>1.7</java.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+
+ <!-- Testing Configuration -->
+ <includedTestGroups/>
+ <excludedTestGroups>Integration,Acceptance,Live,Live-sanity,WIP,Broken</excludedTestGroups>
+ <surefire.failIfNoSpecifiedTests>false</surefire.failIfNoSpecifiedTests>
+
+ <!-- Dependency Versions -->
+ <logback.version>1.0.7</logback.version>
+ <slf4j.version>1.6.6</slf4j.version> <!-- used for java.util.logging jul-to-slf4j interception -->
+ <guava.version>16.0.1</guava.version>
+ <resteasy.version>3.0.8.Final</resteasy.version>
+ <cxf.version>3.1.4</cxf.version>
+ <httpclient.version>4.4.1</httpclient.version>
+ <jsr305.version>2.0.1</jsr305.version>
+ <gson.version>2.3</gson.version>
+ <jetty.version>9.2.13.v20150730</jetty.version>
+ <jetty-schemas.version>3.1.M0</jetty-schemas.version>
+ <mockwebserver.version>20121111</mockwebserver.version>
+
+ <!-- Testing Dependency Versions -->
+ <testng.version>6.8.8</testng.version>
+ <mockito.version>1.10.8</mockito.version>
+ <assertj.version>2.2.0</assertj.version> <!-- v 2.2.0 is being used as v 3.20 introduces Java8 dependencies-->
+ <cobertura.plugin.version>2.7</cobertura.plugin.version>
+ <surefire.version>2.18.1</surefire.version>
+ <plantuml.version>6121</plantuml.version>
+ <ant.version>1.8.4</ant.version>
+
+ <!-- Build Tool Versions -->
+ <maven-war-plugin.version>2.4</maven-war-plugin.version>
+ <maven-dependency-plugin.version>2.8</maven-dependency-plugin.version>
+ <maven-replacer-plugin.version>1.5.2</maven-replacer-plugin.version>
+ <nodejs-maven-plugin.version>1.0.3</nodejs-maven-plugin.version>
+ <nodejs-maven-binaries.version>0.10.25</nodejs-maven-binaries.version>
+ <jasmine-maven-plugin.version>1.3.1.5</jasmine-maven-plugin.version>
+ <requirejs-maven-plugin.version>2.0.0</requirejs-maven-plugin.version>
+ <maven-antrun-plugin.version>1.7</maven-antrun-plugin.version>
- <properties>
- <maven.antrun.plugin.version>1.8</maven.antrun.plugin.version>
- <maven.assembly.plugin.version>2.6</maven.assembly.plugin.version>
- <target>all</target>
</properties>
- <repositories>
- <!--
- Same as in the parent apache pom. Repeated here in case
- direct parent's pom not found at relativePath. Can't fetch
- the parent from remote repos for snapshot versions - no
- snapshot repos enabled by default.
- -->
- <repository>
- <id>apache.snapshots</id>
- <name>Apache Snapshot Repository</name>
- <url>http://repository.apache.org/snapshots</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- </repository>
- </repositories>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>${guava.version}</version>
+ </dependency>
+ <!-- JAX-RS 2.0 RESTEasy Implementation -->
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>${resteasy.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jackson2-provider</artifactId>
+ <version>${resteasy.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>jaxrs-api</artifactId>
+ <version>${resteasy.version}</version>
+ </dependency>
+ <!-- / JAX-RS -->
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>${httpclient.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ <version>${jsr305.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${gson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>${testng.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.mockwebserver</groupId>
+ <artifactId>mockwebserver</artifactId>
+ <version>${mockwebserver.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <modules>
+ <module>cli</module>
+ <module>java</module>
+ </modules>
<build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.8</version>
- <executions>
- <execution>
- <id>process-build-all</id>
- <phase>compile</phase>
- <configuration>
- <target>
- <ant target="${target}"/>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>${maven.assembly.plugin.version}</version>
- <configuration>
- <descriptors>
- <descriptor>release/assembly.xml</descriptor>
- </descriptors>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <version>0.11</version>
- <configuration>
- <excludes combine.children="append">
- <exclude>vendor/**</exclude>
- <exclude>glide.*</exclude>
- </excludes>
- </configuration>
- </plugin>
-
- </plugins>
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ </testResources>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.8</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>2.6.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.8.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.10</version>
+ <configuration>
+ <additionalProjectnatures>
+ <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
+ </additionalProjectnatures>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.4.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.18.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <!-- version 2.4+ seems to break eclipse integration as per https://github.com/tesla/m2eclipse-extras/issues/10
+ but cannot find issue on GitHub any more - 404 error -->
+ <!-- XXX if this version is changed, update the MavenArtifactTest -->
+ <version>2.6</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.3</version>
+ <configuration>
+ <!-- disabling use because of NPE deploying to sonatype:
+ http://stackoverflow.com/questions/888199/why-does-maven-install-fail-during-javadoc-generation
+ http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=ac084ab7f47c4e7f1df2117cecd?bug_id=5101868
+ -->
+ <use>false</use>
+ <links>
+ <link>http://download.oracle.com/javaee/6/api</link>
+ </links>
+ <keywords>true</keywords>
+ <author>false</author>
+ <quiet>true</quiet>
+ <aggregate>false</aggregate>
+ <failOnError>false</failOnError>
+ <detectLinks/>
+ <tags>
+ <tag>
+ <name>todo</name>
+ <placement>a</placement>
+ <head>To-do:</head>
+ </tag>
+ </tags>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.7</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.3</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <shadedArtifactAttached>true</shadedArtifactAttached>
+ <shadedClassifierName>with-dependencies</shadedClassifierName>
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA</exclude>
+ <exclude>META-INF/*.RSA</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.4</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.4</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>jar-no-fork</goal>
+ <goal>test-jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <configuration>
+ <argLine>-Xms768m -Xmx768m -XX:MaxPermSize=256m -verbose:gc</argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.5.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>3.0.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.9.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>${cobertura.plugin.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>com.google.code.maven-replacer-plugin</groupId>
+ <artifactId>maven-replacer-plugin</artifactId>
+ <version>1.4.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>buildnumber-maven-plugin</artifactId>
+ <version>1.3</version>
+ <configuration>
+ <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <version>0.11</version>
+ <configuration>
+ <excludes combine.children="append">
+ <!-- Exclude sandbox because not part of distribution: not in tgz, and not uploaded to maven-central -->
+ <exclude>sandbox/**</exclude>
+ <!-- Exclude release because not part of distribution: not in tgz, and not uploaded to maven-central -->
+ <exclude>release/**</exclude>
+ <exclude>README.md</exclude>
+ <!-- Exclude netbeans config files (not part of the project, but often on users' drives -->
+ <exclude>**/nbactions.xml</exclude>
+ <exclude>**/nb-configuration.xml</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <!-- This is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <versionRange>[2.8,)</versionRange>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore/>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <versionRange>[2.4.1,)</versionRange>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore/>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <versionRange>[1.7,)</versionRange>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore/>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <versionRange>[1.3.1,)</versionRange>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore/>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <versionRange>[1.5,)</versionRange>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore/>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <versionRange>[2.8,)</versionRange>
+ <goals>
+ <goal>unpack</goal>
+ <goal>copy</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore/>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <versionRange>[2.13,)</versionRange>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore/>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
</build>
</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/release/assembly.xml
----------------------------------------------------------------------
diff --git a/release/assembly.xml b/release/assembly.xml
deleted file mode 100644
index 8a32f91..0000000
--- a/release/assembly.xml
+++ /dev/null
@@ -1,43 +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.
--->
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
- <id>bin</id>
- <formats>
- <format>zip</format>
- </formats>
- <fileSets>
- <fileSet>
- <directory>release/files</directory>
- <outputDirectory><!-- leave blank, meaning 'root of archive' --></outputDirectory>
- </fileSet>
- <fileSet>
- <directory>release/license/files</directory>
- <outputDirectory><!-- leave blank, meaning 'root of archive' --></outputDirectory>
- </fileSet>
- <fileSet>
- <directory>${project.build.directory}/bin</directory>
- <outputDirectory><!-- leave blank, meaning 'root of archive' --></outputDirectory>
- <includes>
- <include>**/br*</include>
- </includes>
- </fileSet>
- </fileSets>
-</assembly>
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/release/build.bat
----------------------------------------------------------------------
diff --git a/release/build.bat b/release/build.bat
deleted file mode 100644
index cbef33a..0000000
--- a/release/build.bat
+++ /dev/null
@@ -1,24 +0,0 @@
-@echo off
-REM Licensed to the Apache Software Foundation (ASF) under one
-REM or more contributor license agreements. See the NOTICE file
-REM distributed with this work for additional information
-REM regarding copyright ownership. The ASF licenses this file
-REM to you under the Apache License, Version 2.0 (the
-REM "License"); you may not use this file except in compliance
-REM with the License. You may obtain a copy of the License at
-REM
-REM http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing,
-REM software distributed under the License is distributed on an
-REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-REM KIND, either express or implied. See the License for the
-REM specific language governing permissions and limitations
-REM under the License.
-
-REM TODO
-echo.
-echo brooklyn-client CLI build not supported on Windows platforms, run maven with '-Dno-go-client' to skip.
-echo.
-
-exit 1
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/release/build.sh
----------------------------------------------------------------------
diff --git a/release/build.sh b/release/build.sh
deleted file mode 100755
index dfee050..0000000
--- a/release/build.sh
+++ /dev/null
@@ -1,283 +0,0 @@
-#!/usr/bin/env bash
-# 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.
-
-
-#
-# Constants
-#
-OSVALUES="darwin freebsd linux netbsd openbsd windows"
-ARCHVALUES="386 amd64"
-BRNAME="br"
-GOPACKAGE="github.com/apache/brooklyn-client/${BRNAME}"
-PROJECT="github.com/apache/brooklyn-client"
-CLI_PACKAGE="${PROJECT}/${BRNAME}"
-GOBIN=go
-GLIDE=glide
-
-START_TIME=$(date +%s)
-
-#
-# Globals
-#
-os=""
-arch=""
-all=""
-outdir="."
-sourcedir="."
-label=""
-timestamp=""
-
-builds=(
- darwin/amd64
- linux/386
- windows/386
-)
-
-show_help() {
- echo "Usage: $0 [-d <OUTPUTDIR>] [-l <LABEL>] [-t] -s <SOURCEDIR>"
- echo " $0 -o <OS> -a <ARCH> [-d <DIRECTORY>] [-l <LABEL>] [-t] -s <SOURCEDIR>"
- echo " $0 -A [-d <OUTPUTDIR>] [-l <LABEL>] [-t] -s <SOURCEDIR>"
- echo " $0 -h"
- echo
- cat <<-EOH
- -A Build for default OS/ARCH combinations
- -a Set ARCH to build for
- -d Set output directory
- -h Show help
- -l Set label text for including in filename
- -o Set OS to build for
- -t Set timestamp for including in filename
- -s Source directory
-
-EOH
-
- echo $OSVALUES | awk 'BEGIN{printf("Supported OS:\n")};{for(i=1;i<=NF;i++){printf("\t%s\n",$i)}}'
- echo $ARCHVALUES | awk 'BEGIN{printf("Supported ARCH:\n")};{for(i=1;i<=NF;i++){printf("\t%s\n",$i)}}'
- echo Default build:
- for build in ${builds[@]} ; do
- printf "\t%s\n" $build
- done
-}
-
-while [ $# -gt 0 ]; do
- case $1 in
- -h|help)
- show_help
- exit 0
- ;;
- -d)
- if [ $# -lt 2 ]; then
- show_help
- echo "Value for OUTPUTDIR must be provided"
- exit 1
- fi
- outdir="$2"
- shift 2
- ;;
- -s)
- if [ $# -lt 2 ]; then
- show_help
- echo "Value for SOURCEDIR must be provided"
- exit 1
- fi
- sourcedir="$2"
- shift 2
- ;;
- -o)
- if [ $# -lt 2 ]; then
- show_help
- echo "Value for OS must be provided"
- exit 1
- fi
- os="$2"
- shift 2
- ;;
- -a)
- if [ $# -lt 2 ]; then
- show_help
- echo "Value for ARCH must be provided"
- exit 1
- fi
- arch="$2"
- shift 2
- ;;
- -A)
- all="all"
- shift 1
- ;;
- -l)
- if [ $# -lt 2 ]; then
- show_help
- echo "Value for LABEL must be provided"
- exit 1
- fi
- label=".$2"
- shift 2
- ;;
- -t)
- timestamp=`date +.%Y%m%d-%H%M%S`
- shift
- ;;
- *)
- show_help
- echo "Unrecognised parameter: $1"
- exit 1
- ;;
- esac
-done
-
-echo "Starting build.sh (brooklyn-client go build script)"
-
-#
-# Test if go is available
-#
-if ! command -v $GOBIN >/dev/null 2>&1 ; then
- cat 1>&2 << \
---MARKER--
-
-ERROR: Go language binaries not found (running "$GOBIN")
-
-The binaries for go v1.6 must be installed to build the brooklyn-client CLI.
-See golang.org for more information, or run maven with '-Dno-go-client' to skip.
-
---MARKER--
- exit 1
-fi
-
-GO_VERSION=`go version | awk '{print $3}'`
-GO_V=`echo $GO_VERSION | sed 's/^go1\.\([0-9][0-9]*\).*/\1/'`
-# test if not okay so error shows if regex above not matched
-if ! (( "$GO_V" >= 6 )) ; then
- cat 1>&2 << \
---MARKER--
-
-ERROR: Incompatible Go language version: $GO_VERSION
-
-Go version 1.6 or higher is required to build the brooklyn-client CLI.
-See golang.org for more information, or run maven with '-Dno-go-client' to skip.
-
---MARKER--
- exit 1
-fi
-
-
-if [ -n "$outdir" -a ! -d "$outdir" ]; then
- show_help
- echo "No such directory: $outdir"
- exit 1
-fi
-
-# Set GOPATH to $outdir and link to source code.
-export GOPATH=${outdir}
-mkdir -p ${GOPATH}/src/${PROJECT%/*}
-[ -e ${GOPATH}/src/${PROJECT} ] || ln -s ${sourcedir} ${GOPATH}/src/${PROJECT}
-PATH=${GOPATH}/bin:${PATH}
-
-command -v $GLIDE >/dev/null 2>&1 || {
- echo Installing $GLIDE
- go get github.com/Masterminds/glide || { echo failed installing $GLIDE ; exit 1; }
-}
-
-command -v $GLIDE >/dev/null 2>&1 || {
- echo "Command for resolving dependencies ($GLIDE) not found and could not be installed in $GOPATH"
- exit 1
-}
-
-echo "Installing dependencies"
-$GLIDE install
-
-if [ -n "$all" -a \( -n "$os" -o -n "$arch" \) ]; then
- show_help
- echo "OS and ARCH must not be combined with ALL"
- exit 1
-fi
-
-if [ \( -n "$os" -a -z "$arch" \) -o \( -z "$os" -a -n "$arch" \) ]; then
- show_help
- echo "OS and ARCH must be specified"
- exit 1
-fi
-
-EXECUTABLE_DIR="$GOPATH/src/$CLI_PACKAGE"
-if [ -d ${EXECUTABLE_DIR} ]; then
- cd ${EXECUTABLE_DIR}
-else
- echo "Directory not found: ${EXECUTABLE_DIR}"
- exit 2
-fi
-
-mkdir -p ${GOPATH}/bin
-
-# Disable use of C code modules (causes problems with cross-compiling)
-export CGO_ENABLED=0
-
-# build requested file
-function build_cli () {
- local filepath=$1
- mkdir -p ${filepath%/*}
- $GOBIN build -ldflags "-s" -o $filepath $CLI_PACKAGE || return $?
-}
-
-# Do a build for one platorm, usage like: build_for_platform darwin/amd64
-function build_for_platform () {
- local os=${1%/*}
- local arch=${1#*/}
- local BINARY=${BRNAME}
- if [ "windows" = $os ] ; then
- BINARY=${BINARY}.exe
- fi
- GOOS="$os" GOARCH="$arch" build_cli "${GOPATH}/bin/$os.$arch/${BINARY}${label}" || return $?
-}
-
-# Build as instructed
-if [ -z "$os" -a -z "$all" ]; then
- echo "Building $BRNAME for native OS/ARCH"
- build_cli "${GOPATH}/bin/${BRNAME}${label}${timestamp}" || exit $?
-elif [ -z "$all" ]; then
- validos=`expr " $OSVALUES " : ".* $os "`
- if [ "$validos" -eq 0 ]; then
- show_help
- echo "Unrecognised OS: $os"
- exit 1
- fi
- validarch=`expr " $ARCHVALUES " : ".* $arch "`
- if [ "$validarch" -eq 0 ]; then
- show_help
- echo "Unrecognised ARCH: $arch"
- exit 1
- fi
- echo "Building $BRNAME for $os/$arch:"
- build_for_platform $os/$arch || exit $?
-else
- echo "Building $BRNAME for default OS/ARCH:"
- for build in ${builds[@]}; do
- echo " $build"
- build_for_platform $build || exit $?
- done
-fi
-
-echo
-echo Successfully built the following binaries:
-echo
-ls -lR ${GOPATH}/bin
-echo
-
-END_TIME=$(date +%s)
-echo "Completed build.sh (brooklyn-client go build script) in $(( $END_TIME - START_TIME ))s"
-
-exit 0
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/release/files/README
----------------------------------------------------------------------
diff --git a/release/files/README b/release/files/README
deleted file mode 100644
index da1f0a0..0000000
--- a/release/files/README
+++ /dev/null
@@ -1,42 +0,0 @@
-
-Apache Brooklyn Command Line Client
-===================================
-
-What is it?
------------
-
-A command line client, "br", for **[Apache Brooklyn](https://brooklyn.apache.org)**.
-
-With this tool you can deploy and manage applications on a running Brooklyn server.
-
-This file gives a brief summary of how to use the Brooklyn CLI client tool.
-More complete documentation is available **[on the Apache Brooklyn website](https://brooklyn.apache.org/v/latest/ops/cli/cli-ref-guide.html).
-
-
-License
--------
-
-Please see the file [LICENSE](LICENSE).
-
-
-Getting Started
----------------
-
-Find the binary which is right for your platform.
-You'll typically find it in a sub-directory here.
-(Note that "Darwin" is a technical name for "Mac OS X".)
-
-Add it to your path or alias it with `br`.
-
-Then log in to your Brooklyn instance with:
-
- $ br login URL [USER PASSWORD]
-
-See the help command for info on all commands:
-
- $ br help
-
-For help on individual commands:
-
- $ br help COMMAND
-
[10/10] brooklyn-client git commit: This closes brookyln-client #25
Posted by an...@apache.org.
This closes brookyln-client #25
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-client/commit/8d0c3264
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-client/tree/8d0c3264
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-client/diff/8d0c3264
Branch: refs/heads/master
Commit: 8d0c3264ea50310ab15d6b0ef68af2525226b56b
Parents: a191255 4122cfe
Author: Andrea Turli <an...@gmail.com>
Authored: Sat Sep 10 19:13:46 2016 +0200
Committer: Andrea Turli <an...@gmail.com>
Committed: Sat Sep 10 19:13:58 2016 +0200
----------------------------------------------------------------------
.gitignore | 5 +-
LICENSE | 445 ------------
NOTICE | 5 -
README.md | 118 ---
api/access_control/access_control.go | 48 --
api/activities/activities.go | 59 --
api/application/applications.go | 141 ----
api/catalog/catalog.go | 233 ------
api/entities/entities.go | 183 -----
api/entity_config/config.go | 94 ---
api/entity_effectors/effectors.go | 62 --
api/entity_policies/policies.go | 104 ---
api/entity_policy_config/config.go | 65 --
api/entity_sensors/sensors.go | 98 ---
api/locations/locations.go | 77 --
api/server/server.go | 190 -----
api/usage/usage.go | 62 --
api/version/version.go | 36 -
app/app.go | 170 -----
br/brooklyn.go | 65 --
build.xml | 59 --
cli/LICENSE | 445 ++++++++++++
cli/NOTICE | 5 +
cli/README.md | 118 +++
cli/api/access_control/access_control.go | 48 ++
cli/api/activities/activities.go | 59 ++
cli/api/application/applications.go | 141 ++++
cli/api/catalog/catalog.go | 233 ++++++
cli/api/entities/entities.go | 183 +++++
cli/api/entity_config/config.go | 94 +++
cli/api/entity_effectors/effectors.go | 62 ++
cli/api/entity_policies/policies.go | 104 +++
cli/api/entity_policy_config/config.go | 65 ++
cli/api/entity_sensors/sensors.go | 98 +++
cli/api/locations/locations.go | 77 ++
cli/api/server/server.go | 190 +++++
cli/api/usage/usage.go | 62 ++
cli/api/version/version.go | 36 +
cli/app/app.go | 170 +++++
cli/br/brooklyn.go | 65 ++
cli/build.xml | 59 ++
cli/command/command.go | 30 +
cli/command/supercommand.go | 30 +
cli/command_factory/factory.go | 141 ++++
cli/command_metadata/command_metadata.go | 33 +
cli/command_runner/runner.go | 61 ++
cli/commands/access.go | 59 ++
cli/commands/activity-stream.go | 149 ++++
cli/commands/activity.go | 162 +++++
cli/commands/add-catalog.go | 59 ++
cli/commands/add-children.go | 63 ++
cli/commands/add-location.go | 33 +
cli/commands/add-policy.go | 50 ++
cli/commands/application.go | 111 +++
cli/commands/catalog-applications.go | 33 +
cli/commands/catalog-entities.go | 33 +
cli/commands/catalog-entity.go | 33 +
cli/commands/catalog-location.go | 33 +
cli/commands/catalog-locations.go | 33 +
cli/commands/catalog-policies.go | 33 +
cli/commands/catalog-policy.go | 33 +
cli/commands/catalog.go | 63 ++
cli/commands/config.go | 78 ++
cli/commands/delete-catalog-application.go | 33 +
cli/commands/delete-catalog-entity.go | 33 +
cli/commands/delete-catalog-policy.go | 33 +
cli/commands/delete.go | 59 ++
cli/commands/deploy.go | 85 +++
cli/commands/destroy-policy.go | 59 ++
cli/commands/effector.go | 70 ++
cli/commands/entity.go | 127 ++++
cli/commands/invoke.go | 203 ++++++
cli/commands/list.go | 90 +++
cli/commands/locations.go | 63 ++
cli/commands/login.go | 113 +++
cli/commands/policy.go | 114 +++
cli/commands/rename.go | 59 ++
cli/commands/reset-catalog.go | 33 +
cli/commands/sensor.go | 118 +++
cli/commands/set.go | 59 ++
cli/commands/spec.go | 59 ++
cli/commands/start-policy.go | 59 ++
cli/commands/stop-policy.go | 59 ++
cli/commands/tree.go | 78 ++
cli/commands/utils.go | 38 +
cli/commands/version.go | 59 ++
cli/error_handler/error.go | 46 ++
cli/glide.lock | 10 +
cli/glide.yaml | 6 +
cli/io/config.go | 72 ++
cli/models/access.go | 24 +
cli/models/applications.go | 97 +++
cli/models/catalog.go | 63 ++
cli/models/config.go | 31 +
cli/models/effectors.go | 34 +
cli/models/entities.go | 27 +
cli/models/locations.go | 28 +
cli/models/policies.go | 39 +
cli/models/sensors.go | 26 +
cli/models/version.go | 34 +
cli/net/net.go | 211 ++++++
cli/pom.xml | 132 ++++
cli/release/assembly.xml | 43 ++
cli/release/build.bat | 24 +
cli/release/build.sh | 283 ++++++++
cli/release/files/README | 42 ++
cli/release/license/files/LICENSE | 445 ++++++++++++
cli/release/license/source-inclusions.yaml | 24 +
cli/scope/scope.go | 137 ++++
cli/terminal/table.go | 102 +++
cli/test/test.sh | 226 ++++++
cli/test/test_app.yaml | 22 +
command/command.go | 30 -
command/supercommand.go | 30 -
command_factory/factory.go | 141 ----
command_metadata/command_metadata.go | 33 -
command_runner/runner.go | 61 --
commands/access.go | 59 --
commands/activity-stream.go | 149 ----
commands/activity.go | 162 -----
commands/add-catalog.go | 59 --
commands/add-children.go | 63 --
commands/add-location.go | 33 -
commands/add-policy.go | 50 --
commands/application.go | 111 ---
commands/catalog-applications.go | 33 -
commands/catalog-entities.go | 33 -
commands/catalog-entity.go | 33 -
commands/catalog-location.go | 33 -
commands/catalog-locations.go | 33 -
commands/catalog-policies.go | 33 -
commands/catalog-policy.go | 33 -
commands/catalog.go | 63 --
commands/config.go | 78 --
commands/delete-catalog-application.go | 33 -
commands/delete-catalog-entity.go | 33 -
commands/delete-catalog-policy.go | 33 -
commands/delete.go | 59 --
commands/deploy.go | 85 ---
commands/destroy-policy.go | 59 --
commands/effector.go | 70 --
commands/entity.go | 127 ----
commands/invoke.go | 203 ------
commands/list.go | 90 ---
commands/locations.go | 63 --
commands/login.go | 113 ---
commands/policy.go | 114 ---
commands/rename.go | 59 --
commands/reset-catalog.go | 33 -
commands/sensor.go | 118 ---
commands/set.go | 59 --
commands/spec.go | 59 --
commands/start-policy.go | 59 --
commands/stop-policy.go | 59 --
commands/tree.go | 78 --
commands/utils.go | 38 -
commands/version.go | 59 --
error_handler/error.go | 46 --
glide.lock | 10 -
glide.yaml | 6 -
io/config.go | 72 --
java/pom.xml | 719 +++++++++++++++++++
.../brooklyn/rest/client/BrooklynApi.java | 419 +++++++++++
.../brooklyn/rest/client/BrooklynApiUtil.java | 154 ++++
.../util/http/BuiltResponsePreservingError.java | 79 ++
.../ApplicationResourceIntegrationTest.java | 190 +++++
.../rest/client/BrooklynApiRestClientTest.java | 163 +++++
.../rest/client/BrooklynApiUtilTest.java | 129 ++++
.../src/test/resources/catalog/test-catalog.bom | 33 +
java/src/test/webapp/WEB-INF/web.xml | 129 ++++
models/access.go | 24 -
models/applications.go | 97 ---
models/catalog.go | 63 --
models/config.go | 31 -
models/effectors.go | 34 -
models/entities.go | 27 -
models/locations.go | 28 -
models/policies.go | 39 -
models/sensors.go | 26 -
models/version.go | 34 -
net/net.go | 211 ------
pom.xml | 538 +++++++++++---
release/assembly.xml | 43 --
release/build.bat | 24 -
release/build.sh | 283 --------
release/files/README | 42 --
release/license/files/LICENSE | 445 ------------
release/license/source-inclusions.yaml | 24 -
scope/scope.go | 137 ----
terminal/table.go | 102 ---
test/test.sh | 226 ------
test/test_app.yaml | 22 -
192 files changed, 10064 insertions(+), 7558 deletions(-)
----------------------------------------------------------------------
[07/10] brooklyn-client git commit: move rest-client to
brooklyn-client
Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/server/server.go
----------------------------------------------------------------------
diff --git a/cli/api/server/server.go b/cli/api/server/server.go
new file mode 100644
index 0000000..a46b705
--- /dev/null
+++ b/cli/api/server/server.go
@@ -0,0 +1,190 @@
+/*
+ * 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 server
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/net"
+)
+
+func Up(network *net.Network) (string, error) {
+ url := "/v1/server/up"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Version(network *net.Network) (string, error) {
+ url := "/v1/server/version"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func GetConfig(network *net.Network, configKey string) (string, error) {
+ url := fmt.Sprintf("/v1/server/config/%s", configKey)
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Reload(network *net.Network) (string, error) {
+ url := "/v1/server/properties/reload"
+ body, err := network.SendEmptyPostRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Status(network *net.Network) (string, error) {
+ url := "/v1/server/status"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func User(network *net.Network) (string, error) {
+ url := "/v1/server/user"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func ShuttingDown(network *net.Network) (string, error) {
+ url := "/v1/server/shuttingDown"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Healthy(network *net.Network) (string, error) {
+ url := "/v1/server/healthy"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func UpExtended(network *net.Network) (string, error) {
+ url := "/v1/server/up/extended"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func State(network *net.Network) (string, error) {
+ url := "/v1/server/ha/state"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+// WIP
+func SetState(network *net.Network) (string, error) {
+ url := "/v1/server/ha/state"
+ body, err := network.SendEmptyPostRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Metrics(network *net.Network) (string, error) {
+ url := "/v1/server/ha/metrics"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func Priority(network *net.Network) (string, error) {
+ url := "/v1/server/ha/priority"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+// WIP
+func SetPriority(network *net.Network) (string, error) {
+ url := "/v1/server/ha/priority"
+ body, err := network.SendEmptyPostRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
+
+func States(network *net.Network) (string, error) {
+ url := "/v1/server/ha/states"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", nil
+ }
+ return string(body)
+}
+
+// WIP
+func ClearStates(network *net.Network) (string, error) {
+ url := "/v1/server/ha/states/clear"
+ body, err := network.SendEmptyPostRequest(url)
+ if err != nil {
+ return "", nil
+ }
+ return string(body), nil
+}
+
+func Export(network *net.Network) (string, error) {
+ url := "/v1/server/ha/persist/export"
+ body, err := network.SendGetRequest(url)
+ if err != nil {
+ return "", nil
+ }
+ return string(body), nil
+}
+
+// WIP
+func Shutdown(network *net.Network) (string, error) {
+ url := "/v1/server/shutdown"
+ body, err := network.SendEmptyPostRequest(url)
+ if err != nil {
+ return "", err
+ }
+ return string(body), nil
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/api/usage/usage.go
----------------------------------------------------------------------
diff --git a/cli/api/usage/usage.go b/cli/api/usage/usage.go
new file mode 100644
index 0000000..f49a517
--- /dev/null
+++ b/cli/api/usage/usage.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 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/cli/api/version/version.go
----------------------------------------------------------------------
diff --git a/cli/api/version/version.go b/cli/api/version/version.go
new file mode 100644
index 0000000..c3f1c70
--- /dev/null
+++ b/cli/api/version/version.go
@@ -0,0 +1,36 @@
+/*
+ * 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/cli/app/app.go
----------------------------------------------------------------------
diff --git a/cli/app/app.go b/cli/app/app.go
new file mode 100644
index 0000000..afdb41d
--- /dev/null
+++ b/cli/app/app.go
@@ -0,0 +1,170 @@
+/*
+ * 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/cli/br/brooklyn.go
----------------------------------------------------------------------
diff --git a/cli/br/brooklyn.go b/cli/br/brooklyn.go
new file mode 100644
index 0000000..7f5eed5
--- /dev/null
+++ b/cli/br/brooklyn.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 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/cli/build.xml
----------------------------------------------------------------------
diff --git a/cli/build.xml b/cli/build.xml
new file mode 100644
index 0000000..713b339
--- /dev/null
+++ b/cli/build.xml
@@ -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.
+-->
+<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/command/command.go
----------------------------------------------------------------------
diff --git a/cli/command/command.go b/cli/command/command.go
new file mode 100644
index 0000000..1a16282
--- /dev/null
+++ b/cli/command/command.go
@@ -0,0 +1,30 @@
+/*
+ * 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 command
+
+import (
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type Command interface {
+ Metadata() command_metadata.CommandMetadata
+ Run(scope scope.Scope, context *cli.Context)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/command/supercommand.go
----------------------------------------------------------------------
diff --git a/cli/command/supercommand.go b/cli/command/supercommand.go
new file mode 100644
index 0000000..82a5856
--- /dev/null
+++ b/cli/command/supercommand.go
@@ -0,0 +1,30 @@
+/*
+ * 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 command
+
+// A command with further (sub) commands, like 'git remote', with its 'git remote add' etc.
+type SuperCommand interface {
+ Command
+
+ // Get the sub command wih the given name
+ SubCommand(name string) Command
+
+ // Get the names of all subcommands
+ SubCommandNames() []string
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/command_factory/factory.go
----------------------------------------------------------------------
diff --git a/cli/command_factory/factory.go b/cli/command_factory/factory.go
new file mode 100644
index 0000000..7a46eb9
--- /dev/null
+++ b/cli/command_factory/factory.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 command_factory
+
+import (
+ "errors"
+ "github.com/apache/brooklyn-client/command"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/commands"
+ "github.com/apache/brooklyn-client/io"
+ "github.com/apache/brooklyn-client/net"
+ "sort"
+ "strings"
+)
+
+type Factory interface {
+ GetByCmdName(cmdName string) (cmd command.Command, err error)
+ GetBySubCmdName(cmdName string, subCmdName string) (cmd command.Command, err error)
+ CommandMetadatas() []command_metadata.CommandMetadata
+}
+
+type concreteFactory struct {
+ cmdsByName map[string]command.Command
+ subCommands map[string]map[string]command.Command
+}
+
+func NewFactory(network *net.Network, config *io.Config) (factory concreteFactory) {
+ factory.cmdsByName = make(map[string]command.Command)
+ factory.subCommands = make(map[string]map[string]command.Command)
+
+ factory.simpleCommand(commands.NewAccess(network))
+ //factory.command(commands.NewActivities(network))
+ factory.simpleCommand(commands.NewActivity(network))
+ factory.simpleCommand(commands.NewActivityStreamEnv(network))
+ factory.simpleCommand(commands.NewActivityStreamStderr(network))
+ factory.simpleCommand(commands.NewActivityStreamStdin(network))
+ factory.simpleCommand(commands.NewActivityStreamStdout(network))
+ factory.simpleCommand(commands.NewAddCatalog(network))
+ factory.simpleCommand(commands.NewAddChildren(network))
+ factory.simpleCommand(commands.NewApplication(network))
+ //factory.simpleCommand(commands.NewApplications(network))
+ factory.simpleCommand(commands.NewCatalog(network))
+ factory.simpleCommand(commands.NewConfig(network))
+ factory.simpleCommand(commands.NewDeploy(network))
+ factory.simpleCommand(commands.NewDelete(network))
+ factory.simpleCommand(commands.NewDestroyPolicy(network))
+ factory.simpleCommand(commands.NewEffector(network))
+ factory.simpleCommand(commands.NewEntity(network))
+ factory.simpleCommand(commands.NewInvoke(network))
+ factory.simpleCommand(commands.NewInvokeRestart(network))
+ factory.simpleCommand(commands.NewInvokeStart(network))
+ factory.simpleCommand(commands.NewInvokeStop(network))
+ // NewList below is not used but we retain the code as an example of how to do a super command.
+ // factory.superCommand(commands.NewList(network))
+ factory.simpleCommand(commands.NewLocations(network))
+ factory.simpleCommand(commands.NewLogin(network, config))
+ factory.simpleCommand(commands.NewPolicy(network))
+ factory.simpleCommand(commands.NewRename(network))
+ factory.simpleCommand(commands.NewSensor(network))
+ factory.simpleCommand(commands.NewSetConfig(network))
+ factory.simpleCommand(commands.NewSpec(network))
+ factory.simpleCommand(commands.NewStartPolicy(network))
+ factory.simpleCommand(commands.NewStopPolicy(network))
+ factory.simpleCommand(commands.NewTree(network))
+ factory.simpleCommand(commands.NewVersion(network))
+
+ return factory
+}
+
+func (factory *concreteFactory) simpleCommand(cmd command.Command) {
+ factory.cmdsByName[cmd.Metadata().Name] = cmd
+}
+
+func (factory *concreteFactory) superCommand(cmd command.SuperCommand) {
+
+ factory.simpleCommand(cmd)
+
+ if nil == factory.subCommands[cmd.Metadata().Name] {
+ factory.subCommands[cmd.Metadata().Name] = make(map[string]command.Command)
+ }
+
+ for _, sub := range cmd.SubCommandNames() {
+ factory.subCommands[cmd.Metadata().Name][sub] = cmd.SubCommand(sub)
+ }
+}
+
+func (f concreteFactory) GetByCmdName(cmdName string) (cmd command.Command, err error) {
+ cmd, found := f.cmdsByName[cmdName]
+ if !found {
+ for _, c := range f.cmdsByName {
+ if c.Metadata().ShortName == cmdName {
+ return c, nil
+ }
+ }
+
+ err = errors.New(strings.Join([]string{"Command not found:", cmdName}, " "))
+ }
+ return
+}
+
+func (f concreteFactory) GetBySubCmdName(cmdName string, subCmdName string) (cmd command.Command, err error) {
+
+ _, hasPrimary := f.subCommands[cmdName]
+ if hasPrimary {
+ cmd, found := f.subCommands[cmdName][subCmdName]
+ if found {
+ return cmd, nil
+ }
+ }
+ return cmd, errors.New(strings.Join([]string{"Command not found:", cmdName, subCmdName}, " "))
+}
+
+func (factory concreteFactory) CommandMetadatas() (commands []command_metadata.CommandMetadata) {
+ keys := make([]string, 0, len(factory.cmdsByName))
+ for key := range factory.cmdsByName {
+ keys = append(keys, key)
+ }
+ sort.Strings(keys)
+
+ for _, key := range keys {
+ command := factory.cmdsByName[key]
+ commands = append(commands, command.Metadata())
+ }
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/command_metadata/command_metadata.go
----------------------------------------------------------------------
diff --git a/cli/command_metadata/command_metadata.go b/cli/command_metadata/command_metadata.go
new file mode 100644
index 0000000..eac321f
--- /dev/null
+++ b/cli/command_metadata/command_metadata.go
@@ -0,0 +1,33 @@
+/*
+ * 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 command_metadata
+
+import "github.com/urfave/cli"
+
+type CommandMetadata struct {
+ Name string
+ Aliases []string
+ ShortName string
+ Usage string
+ Description string
+ Flags []cli.Flag
+ SkipFlagParsing bool
+ TotalArgs int //Optional: number of required arguments to skip for flag verification
+ Operands []CommandMetadata
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/command_runner/runner.go
----------------------------------------------------------------------
diff --git a/cli/command_runner/runner.go b/cli/command_runner/runner.go
new file mode 100644
index 0000000..c123b5f
--- /dev/null
+++ b/cli/command_runner/runner.go
@@ -0,0 +1,61 @@
+/*
+ * 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 command_runner
+
+import (
+ "github.com/apache/brooklyn-client/command_factory"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type Runner interface {
+ RunCmdByName(cmdName string, c *cli.Context) (err error)
+ RunSubCmdByName(cmdName string, subCommand string, c *cli.Context) (err error)
+}
+
+type ConcreteRunner struct {
+ cmdFactory command_factory.Factory
+ scope scope.Scope
+}
+
+func NewRunner(scope scope.Scope, cmdFactory command_factory.Factory) (runner ConcreteRunner) {
+ runner.cmdFactory = cmdFactory
+ runner.scope = scope
+ return
+}
+
+func (runner ConcreteRunner) RunCmdByName(cmdName string, c *cli.Context) error {
+ cmd, err := runner.cmdFactory.GetByCmdName(cmdName)
+ if nil != err {
+ return err
+ }
+
+ cmd.Run(runner.scope, c)
+ return nil
+}
+
+func (runner ConcreteRunner) RunSubCmdByName(cmdName string, subCommand string, c *cli.Context) error {
+ cmd, err := runner.cmdFactory.GetBySubCmdName(cmdName, subCommand)
+ if nil != err {
+ return err
+ }
+
+ cmd.Run(runner.scope, c)
+ return nil
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/access.go
----------------------------------------------------------------------
diff --git a/cli/commands/access.go b/cli/commands/access.go
new file mode 100644
index 0000000..87e26cd
--- /dev/null
+++ b/cli/commands/access.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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/access_control"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type Access struct {
+ network *net.Network
+}
+
+func NewAccess(network *net.Network) (cmd *Access) {
+ cmd = new(Access)
+ cmd.network = network
+ return
+}
+
+func (cmd *Access) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "access",
+ Description: "Show access control",
+ Usage: "BROOKLYN_NAME access",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Access) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ access, err := access_control.Access(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println("Location Provisioning Allowed:", access.LocationProvisioningAllowed)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/activity-stream.go
----------------------------------------------------------------------
diff --git a/cli/commands/activity-stream.go b/cli/commands/activity-stream.go
new file mode 100644
index 0000000..eceadc4
--- /dev/null
+++ b/cli/commands/activity-stream.go
@@ -0,0 +1,149 @@
+/*
+ * 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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/activities"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type ActivityStreamEnv struct {
+ network *net.Network
+}
+
+type ActivityStreamStderr struct {
+ network *net.Network
+}
+
+type ActivityStreamStdin struct {
+ network *net.Network
+}
+
+type ActivityStreamStdout struct {
+ network *net.Network
+}
+
+func NewActivityStreamEnv(network *net.Network) (cmd *ActivityStreamEnv) {
+ cmd = new(ActivityStreamEnv)
+ cmd.network = network
+ return
+}
+
+func NewActivityStreamStderr(network *net.Network) (cmd *ActivityStreamStderr) {
+ cmd = new(ActivityStreamStderr)
+ cmd.network = network
+ return
+}
+
+func NewActivityStreamStdin(network *net.Network) (cmd *ActivityStreamStdin) {
+ cmd = new(ActivityStreamStdin)
+ cmd.network = network
+ return
+}
+
+func NewActivityStreamStdout(network *net.Network) (cmd *ActivityStreamStdout) {
+ cmd = new(ActivityStreamStdout)
+ cmd.network = network
+ return
+}
+
+func (cmd *ActivityStreamEnv) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "env",
+ Description: "Show the ENV stream for a given activity",
+ Usage: "BROOKLYN_NAME ACTIVITY-SCOPE env",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *ActivityStreamStderr) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "stderr",
+ Description: "Show the STDERR stream for a given activity",
+ Usage: "BROOKLYN_NAME ACTIVITY-SCOPE stderr",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *ActivityStreamStdin) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "stdin",
+ Description: "Show the STDIN stream for a given activity",
+ Usage: "BROOKLYN_NAME ACTIVITY-SCOPE ] stdin",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *ActivityStreamStdout) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "stdout",
+ Description: "Show the STDOUT stream for a given activity",
+ Usage: "BROOKLYN_NAME ACTIVITY-SCOPE stdout",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *ActivityStreamEnv) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "env")
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(activityStream)
+}
+
+func (cmd *ActivityStreamStderr) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "stderr")
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(activityStream)
+}
+
+func (cmd *ActivityStreamStdin) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "stdin")
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(activityStream)
+}
+
+func (cmd *ActivityStreamStdout) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "stdout")
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(activityStream)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/activity.go
----------------------------------------------------------------------
diff --git a/cli/commands/activity.go b/cli/commands/activity.go
new file mode 100644
index 0000000..d748c1a
--- /dev/null
+++ b/cli/commands/activity.go
@@ -0,0 +1,162 @@
+/*
+ * 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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/activities"
+ "github.com/apache/brooklyn-client/api/entities"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/urfave/cli"
+ "sort"
+ "strconv"
+ "strings"
+ "time"
+)
+
+type Activity struct {
+ network *net.Network
+}
+
+func NewActivity(network *net.Network) (cmd *Activity) {
+ cmd = new(Activity)
+ cmd.network = network
+ return
+}
+
+func (cmd *Activity) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "activity",
+ Aliases: []string{"activities", "act", "acts"},
+ Description: "Show the activity for an application / entity",
+ Usage: "BROOKLYN_NAME SCOPE activity [ ACTIVITYID]",
+ Flags: []cli.Flag{
+ cli.StringSliceFlag{
+ Name: "children, c",
+ Usage: "List children of the activity",
+ },
+ },
+ }
+}
+
+func (cmd *Activity) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ if c.NumFlags() > 0 && c.FlagNames()[0] == "children" {
+ cmd.listchildren(c.StringSlice("children")[0])
+ } else {
+ if c.Args().Present() {
+ cmd.show(c.Args().First())
+ } else {
+ if scope.Activity == "" {
+ cmd.list(scope.Application, scope.Entity)
+ } else {
+ cmd.listchildren(scope.Activity)
+ }
+ }
+ }
+}
+
+func (cmd *Activity) show(activityId string) {
+ activity, err := activities.Activity(cmd.network, activityId)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+
+ table := terminal.NewTable([]string{"Id:", activity.Id})
+ table.Add("DisplayName:", activity.DisplayName)
+ table.Add("Description:", activity.Description)
+ table.Add("EntityId:", activity.EntityId)
+ table.Add("EntityDisplayName:", activity.EntityDisplayName)
+ table.Add("Submitted:", time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate))
+ table.Add("Started:", time.Unix(activity.StartTimeUtc/1000, 0).Format(time.UnixDate))
+ table.Add("Ended:", time.Unix(activity.EndTimeUtc/1000, 0).Format(time.UnixDate))
+ table.Add("CurrentStatus:", activity.CurrentStatus)
+ table.Add("IsError:", strconv.FormatBool(activity.IsError))
+ table.Add("IsCancelled:", strconv.FormatBool(activity.IsCancelled))
+ table.Add("SubmittedByTask:", activity.SubmittedByTask.Metadata.Id)
+ if activity.Streams["stdin"].Metadata.Size > 0 ||
+ activity.Streams["stdout"].Metadata.Size > 0 ||
+ activity.Streams["stderr"].Metadata.Size > 0 ||
+ activity.Streams["env"].Metadata.Size > 0 {
+ table.Add("Streams:", fmt.Sprintf("stdin: %d, stdout: %d, stderr: %d, env %d",
+ activity.Streams["stdin"].Metadata.Size,
+ activity.Streams["stdout"].Metadata.Size,
+ activity.Streams["stderr"].Metadata.Size,
+ activity.Streams["env"].Metadata.Size))
+ } else {
+ table.Add("Streams:", "")
+ }
+ table.Add("DetailedStatus:", fmt.Sprintf("\"%s\"", activity.DetailedStatus))
+ table.Print()
+}
+
+func (cmd *Activity) list(application, entity string) {
+ activityList, err := entities.GetActivities(cmd.network, application, entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Task", "Submitted", "Status", "Streams"})
+ for _, activity := range activityList {
+ table.Add(activity.Id,
+ truncate(activity.DisplayName),
+ time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate), truncate(activity.CurrentStatus),
+ streams(activity))
+ }
+ table.Print()
+}
+
+func (cmd *Activity) listchildren(activity string) {
+ activityList, err := activities.ActivityChildren(cmd.network, activity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Task", "Submitted", "Status", "Streams"})
+ for _, activity := range activityList {
+ table.Add(activity.Id,
+ truncate(activity.DisplayName),
+ time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate), truncate(activity.CurrentStatus),
+ streams(activity))
+ }
+ table.Print()
+}
+
+func streams(act models.TaskSummary) string {
+ names := make([]string, 0)
+ for name, _ := range act.Streams {
+ names = append(names, name)
+ }
+ sort.Strings(names)
+ return strings.Join(names, ",")
+}
+
+const truncLimit = 40
+
+func truncate(text string) string {
+ if len(text) < truncLimit {
+ return text
+ }
+ return text[0:(truncLimit-3)] + "..."
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/add-catalog.go
----------------------------------------------------------------------
diff --git a/cli/commands/add-catalog.go b/cli/commands/add-catalog.go
new file mode 100644
index 0000000..b161f8b
--- /dev/null
+++ b/cli/commands/add-catalog.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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/catalog"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type AddCatalog struct {
+ network *net.Network
+}
+
+func NewAddCatalog(network *net.Network) (cmd *AddCatalog) {
+ cmd = new(AddCatalog)
+ cmd.network = network
+ return
+}
+
+func (cmd *AddCatalog) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "add-catalog",
+ Description: "* Add a new catalog item from the supplied YAML (a file or http URL)",
+ Usage: "BROOKLYN_NAME add-catalog ( FILEPATH | URL )",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *AddCatalog) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ create, err := catalog.AddCatalog(cmd.network, c.Args().First())
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(create)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/add-children.go
----------------------------------------------------------------------
diff --git a/cli/commands/add-children.go b/cli/commands/add-children.go
new file mode 100644
index 0000000..d05a114
--- /dev/null
+++ b/cli/commands/add-children.go
@@ -0,0 +1,63 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/api/entities"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/urfave/cli"
+ "time"
+)
+
+type AddChildren struct {
+ network *net.Network
+}
+
+func NewAddChildren(network *net.Network) (cmd *AddChildren) {
+ cmd = new(AddChildren)
+ cmd.network = network
+ return
+}
+
+func (cmd *AddChildren) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "add-children",
+ Description: "* Add a child or children to this entity from the supplied YAML",
+ Usage: "BROOKLYN_NAME SCOPE add-children ( FILEPATH | URL )",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *AddChildren) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ activity, err := entities.AddChildren(cmd.network, scope.Application, scope.Entity, c.Args().First())
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Task", "Submitted", "Status"})
+ table.Add(activity.Id, activity.DisplayName, time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate), activity.CurrentStatus)
+
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/add-location.go
----------------------------------------------------------------------
diff --git a/cli/commands/add-location.go b/cli/commands/add-location.go
new file mode 100644
index 0000000..32c2db0
--- /dev/null
+++ b/cli/commands/add-location.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type AddLocation struct {
+ network *net.Network
+}
+
+func NewAddLocation(network *net.Network) (cmd *AddLocation) {
+ cmd = new(AddLocation)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/add-policy.go
----------------------------------------------------------------------
diff --git a/cli/commands/add-policy.go b/cli/commands/add-policy.go
new file mode 100644
index 0000000..35de8c4
--- /dev/null
+++ b/cli/commands/add-policy.go
@@ -0,0 +1,50 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/urfave/cli"
+ //"github.com/apache/brooklyn-client/api/entity_policies"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+)
+
+type AddPolicy struct {
+ network *net.Network
+}
+
+func NewAddPolicy(network *net.Network) (cmd *AddPolicy) {
+ cmd = new(AddPolicy)
+ cmd.network = network
+ return
+}
+
+func (cmd *AddPolicy) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "add-policy",
+ Description: "Add a new policy",
+ Usage: "BROOKLYN_NAME [ SCOPE ] add-policy APPLICATION ENTITY POLICY_TYPE",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *AddPolicy) Run(scope scope.Scope, c *cli.Context) {
+ // Todo
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/application.go
----------------------------------------------------------------------
diff --git a/cli/commands/application.go b/cli/commands/application.go
new file mode 100644
index 0000000..c321227
--- /dev/null
+++ b/cli/commands/application.go
@@ -0,0 +1,111 @@
+/*
+ * 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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/application"
+ "github.com/apache/brooklyn-client/api/entities"
+ "github.com/apache/brooklyn-client/api/entity_sensors"
+ "github.com/apache/brooklyn-client/api/locations"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/urfave/cli"
+ "strings"
+)
+
+type Application struct {
+ network *net.Network
+}
+
+func NewApplication(network *net.Network) (cmd *Application) {
+ cmd = new(Application)
+ cmd.network = network
+ return
+}
+
+func (cmd *Application) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "application",
+ Aliases: []string{"applications", "app", "apps"},
+ Description: "Show the status and location of running applications",
+ Usage: "BROOKLYN_NAME application [APP]",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Application) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ if c.Args().Present() {
+ cmd.show(c.Args().First())
+ } else {
+ cmd.list()
+ }
+}
+
+const serviceIsUpStr = "service.isUp"
+
+func (cmd *Application) show(appName string) {
+ application, err := application.Application(cmd.network, appName)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ entity, err := entities.GetEntity(cmd.network, appName, appName)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ state, err := entity_sensors.CurrentState(cmd.network, appName, appName)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ location, err := locations.GetLocation(cmd.network, application.Spec.Locations[0])
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id:", application.Id})
+ table.Add("Name:", application.Spec.Name)
+ table.Add("Status:", string(application.Status))
+ if serviceUp, ok := state[serviceIsUpStr]; ok {
+ table.Add("ServiceUp:", fmt.Sprintf("%v", serviceUp))
+ }
+ table.Add("Type:", application.Spec.Type)
+ table.Add("CatalogItemId:", entity.CatalogItemId)
+ table.Add("LocationId:", strings.Join(application.Spec.Locations, ", "))
+ table.Add("LocationName:", location.Name)
+ table.Add("LocationSpec:", location.Spec)
+ table.Add("LocationType:", location.Type)
+ table.Print()
+}
+
+func (cmd *Application) list() {
+ applications, err := application.Applications(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Name", "Status", "Location"})
+ for _, app := range applications {
+ table.Add(app.Id, app.Spec.Name, string(app.Status), strings.Join(app.Spec.Locations, ", "))
+ }
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/catalog-applications.go
----------------------------------------------------------------------
diff --git a/cli/commands/catalog-applications.go b/cli/commands/catalog-applications.go
new file mode 100644
index 0000000..19a4373
--- /dev/null
+++ b/cli/commands/catalog-applications.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogApplication struct {
+ network *net.Network
+}
+
+func NewCatalogApplication(network *net.Network) (cmd *CatalogApplication) {
+ cmd = new(CatalogApplication)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/catalog-entities.go
----------------------------------------------------------------------
diff --git a/cli/commands/catalog-entities.go b/cli/commands/catalog-entities.go
new file mode 100644
index 0000000..dbec760
--- /dev/null
+++ b/cli/commands/catalog-entities.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogEntities struct {
+ network *net.Network
+}
+
+func NewCatalogEntities(network *net.Network) (cmd *CatalogEntities) {
+ cmd = new(CatalogEntities)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/catalog-entity.go
----------------------------------------------------------------------
diff --git a/cli/commands/catalog-entity.go b/cli/commands/catalog-entity.go
new file mode 100644
index 0000000..23cc295
--- /dev/null
+++ b/cli/commands/catalog-entity.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogEntity struct {
+ network *net.Network
+}
+
+func NewCatalogEntity(network *net.Network) (cmd *CatalogEntity) {
+ cmd = new(CatalogEntity)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/catalog-location.go
----------------------------------------------------------------------
diff --git a/cli/commands/catalog-location.go b/cli/commands/catalog-location.go
new file mode 100644
index 0000000..40babdd
--- /dev/null
+++ b/cli/commands/catalog-location.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogLocation struct {
+ network *net.Network
+}
+
+func NewCatalogLocation(network *net.Network) (cmd *CatalogLocation) {
+ cmd = new(CatalogLocation)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/catalog-locations.go
----------------------------------------------------------------------
diff --git a/cli/commands/catalog-locations.go b/cli/commands/catalog-locations.go
new file mode 100644
index 0000000..e1791e8
--- /dev/null
+++ b/cli/commands/catalog-locations.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogLocations struct {
+ network *net.Network
+}
+
+func NewCatalogLocations(network *net.Network) (cmd *CatalogLocations) {
+ cmd = new(CatalogLocations)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/catalog-policies.go
----------------------------------------------------------------------
diff --git a/cli/commands/catalog-policies.go b/cli/commands/catalog-policies.go
new file mode 100644
index 0000000..3e245db
--- /dev/null
+++ b/cli/commands/catalog-policies.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogPolicies struct {
+ network *net.Network
+}
+
+func NewCatalogPolicies(network *net.Network) (cmd *CatalogPolicies) {
+ cmd = new(CatalogPolicies)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/catalog-policy.go
----------------------------------------------------------------------
diff --git a/cli/commands/catalog-policy.go b/cli/commands/catalog-policy.go
new file mode 100644
index 0000000..82e8a95
--- /dev/null
+++ b/cli/commands/catalog-policy.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogPolicy struct {
+ network *net.Network
+}
+
+func NewCatalogPolicy(network *net.Network) (cmd *CatalogPolicy) {
+ cmd = new(CatalogPolicy)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/catalog.go
----------------------------------------------------------------------
diff --git a/cli/commands/catalog.go b/cli/commands/catalog.go
new file mode 100644
index 0000000..fd1d8ad
--- /dev/null
+++ b/cli/commands/catalog.go
@@ -0,0 +1,63 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/api/catalog"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/urfave/cli"
+)
+
+type Catalog struct {
+ network *net.Network
+}
+
+func NewCatalog(network *net.Network) (cmd *Catalog) {
+ cmd = new(Catalog)
+ cmd.network = network
+ return
+}
+
+func (cmd *Catalog) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "catalog",
+ Description: "* List the available catalog applications",
+ Usage: "BROOKLYN_NAME catalog",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Catalog) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ catalog, err := catalog.Catalog(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Name", "Description"})
+ for _, app := range catalog {
+ table.Add(app.Id, app.Name, app.Description)
+ }
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/config.go
----------------------------------------------------------------------
diff --git a/cli/commands/config.go b/cli/commands/config.go
new file mode 100644
index 0000000..33d9cba
--- /dev/null
+++ b/cli/commands/config.go
@@ -0,0 +1,78 @@
+/*
+ * 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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entity_config"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/urfave/cli"
+)
+
+type Config struct {
+ network *net.Network
+}
+
+func NewConfig(network *net.Network) (cmd *Config) {
+ cmd = new(Config)
+ cmd.network = network
+ return
+}
+
+func (cmd *Config) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "config",
+ Description: "Show the config for an application or entity",
+ Usage: "BROOKLYN_NAME SCOPE config",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Config) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ if c.Args().Present() {
+ configValue, err := entity_config.ConfigValue(cmd.network, scope.Application, scope.Entity, c.Args().First())
+
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ displayValue, err := stringRepresentation(configValue)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(displayValue)
+
+ } else {
+ config, err := entity_config.ConfigCurrentState(cmd.network, scope.Application, scope.Entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Key", "Value"})
+ for key, value := range config {
+ table.Add(key, fmt.Sprintf("%v", value))
+ }
+ table.Print()
+ }
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/delete-catalog-application.go
----------------------------------------------------------------------
diff --git a/cli/commands/delete-catalog-application.go b/cli/commands/delete-catalog-application.go
new file mode 100644
index 0000000..f289bbd
--- /dev/null
+++ b/cli/commands/delete-catalog-application.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type DeleteCatalogApplication struct {
+ network *net.Network
+}
+
+func NewDeleteCatalogApplication(network *net.Network) (cmd *DeleteCatalogApplication) {
+ cmd = new(DeleteCatalogApplication)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/delete-catalog-entity.go
----------------------------------------------------------------------
diff --git a/cli/commands/delete-catalog-entity.go b/cli/commands/delete-catalog-entity.go
new file mode 100644
index 0000000..5953fff
--- /dev/null
+++ b/cli/commands/delete-catalog-entity.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type DeleteCatalogEntity struct {
+ network *net.Network
+}
+
+func NewDeleteCatalogEntity(network *net.Network) (cmd *DeleteCatalogEntity) {
+ cmd = new(DeleteCatalogEntity)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/delete-catalog-policy.go
----------------------------------------------------------------------
diff --git a/cli/commands/delete-catalog-policy.go b/cli/commands/delete-catalog-policy.go
new file mode 100644
index 0000000..c6b29a6
--- /dev/null
+++ b/cli/commands/delete-catalog-policy.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type DeleteCatalogPolicy struct {
+ network *net.Network
+}
+
+func NewDeleteCatalogPolicy(network *net.Network) (cmd *DeleteCatalogPolicy) {
+ cmd = new(DeleteCatalogPolicy)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/delete.go
----------------------------------------------------------------------
diff --git a/cli/commands/delete.go b/cli/commands/delete.go
new file mode 100644
index 0000000..90c60f9
--- /dev/null
+++ b/cli/commands/delete.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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/application"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type Delete struct {
+ network *net.Network
+}
+
+func NewDelete(network *net.Network) (cmd *Delete) {
+ cmd = new(Delete)
+ cmd.network = network
+ return
+}
+
+func (cmd *Delete) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "delete",
+ Description: "* Delete (expunge) a brooklyn application",
+ Usage: "BROOKLYN_NAME SCOPE delete",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Delete) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ del, err := application.Delete(cmd.network, scope.Application)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(del)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/deploy.go
----------------------------------------------------------------------
diff --git a/cli/commands/deploy.go b/cli/commands/deploy.go
new file mode 100644
index 0000000..bc42b08
--- /dev/null
+++ b/cli/commands/deploy.go
@@ -0,0 +1,85 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/api/application"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/urfave/cli"
+ "io/ioutil"
+ "os"
+ "strings"
+)
+
+type Deploy struct {
+ network *net.Network
+}
+
+func NewDeploy(network *net.Network) (cmd *Deploy) {
+ cmd = new(Deploy)
+ cmd.network = network
+ return
+}
+
+func (cmd *Deploy) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "deploy",
+ Description: "Deploy a new application from the given YAML (read from file or URL, or stdin)",
+ Usage: "BROOKLYN_NAME deploy ( FILE | URL | '-' )",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Deploy) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+
+ var create models.TaskSummary
+ var err error
+ var blueprint []byte
+ if c.Args().First() == "" {
+ error_handler.ErrorExit("A filename or URL or '-' must be provided as the first argument", error_handler.CLIUsageErrorExitCode)
+ }
+ if c.Args().First() == "-" {
+ blueprint, err = ioutil.ReadAll(os.Stdin)
+ if err != nil {
+ error_handler.ErrorExit(err)
+ }
+ create, err = application.CreateFromBytes(cmd.network, blueprint)
+ } else {
+ create, err = application.Create(cmd.network, c.Args().First())
+ }
+ if nil != err {
+ if httpErr, ok := err.(net.HttpError); ok {
+ error_handler.ErrorExit(strings.Join([]string{httpErr.Status, httpErr.Body}, "\n"), httpErr.Code)
+ } else {
+ error_handler.ErrorExit(err)
+ }
+ }
+ table := terminal.NewTable([]string{"Id:", create.EntityId})
+ table.Add("Name:", create.EntityDisplayName)
+ table.Add("Status:", create.CurrentStatus)
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/destroy-policy.go
----------------------------------------------------------------------
diff --git a/cli/commands/destroy-policy.go b/cli/commands/destroy-policy.go
new file mode 100644
index 0000000..4ea37ec
--- /dev/null
+++ b/cli/commands/destroy-policy.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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entity_policies"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type DestroyPolicy struct {
+ network *net.Network
+}
+
+func NewDestroyPolicy(network *net.Network) (cmd *DestroyPolicy) {
+ cmd = new(DestroyPolicy)
+ cmd.network = network
+ return
+}
+
+func (cmd *DestroyPolicy) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "destroy-policy",
+ Description: "Destroy a policy",
+ Usage: "BROOKLYN_NAME SCOPE destroy-policy POLICY",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *DestroyPolicy) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ spec, err := entity_policies.DestroyPolicy(cmd.network, scope.Application, scope.Entity, c.Args().First())
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(spec)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/effector.go
----------------------------------------------------------------------
diff --git a/cli/commands/effector.go b/cli/commands/effector.go
new file mode 100644
index 0000000..aeff664
--- /dev/null
+++ b/cli/commands/effector.go
@@ -0,0 +1,70 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/api/entity_effectors"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/urfave/cli"
+ "strings"
+)
+
+type Effector struct {
+ network *net.Network
+}
+
+func NewEffector(network *net.Network) (cmd *Effector) {
+ cmd = new(Effector)
+ cmd.network = network
+ return
+}
+
+func (cmd *Effector) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "effector",
+ Description: "Show the effectors for an application or entity",
+ Usage: "BROOKLYN_NAME SCOPE effector [ NAME ]",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Effector) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ effectors, err := entity_effectors.EffectorList(cmd.network, scope.Application, scope.Entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Name", "Description", "Parameters"})
+ for _, effector := range effectors {
+ var parameters []string
+ for _, parameter := range effector.Parameters {
+ parameters = append(parameters, parameter.Name)
+ }
+ if !c.Args().Present() || c.Args().First() == effector.Name {
+ table.Add(effector.Name, effector.Description, strings.Join(parameters, ","))
+ }
+ }
+ table.Print()
+}
[05/10] brooklyn-client git commit: move rest-client to
brooklyn-client
Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/release/build.sh
----------------------------------------------------------------------
diff --git a/cli/release/build.sh b/cli/release/build.sh
new file mode 100755
index 0000000..dfee050
--- /dev/null
+++ b/cli/release/build.sh
@@ -0,0 +1,283 @@
+#!/usr/bin/env bash
+# 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.
+
+
+#
+# Constants
+#
+OSVALUES="darwin freebsd linux netbsd openbsd windows"
+ARCHVALUES="386 amd64"
+BRNAME="br"
+GOPACKAGE="github.com/apache/brooklyn-client/${BRNAME}"
+PROJECT="github.com/apache/brooklyn-client"
+CLI_PACKAGE="${PROJECT}/${BRNAME}"
+GOBIN=go
+GLIDE=glide
+
+START_TIME=$(date +%s)
+
+#
+# Globals
+#
+os=""
+arch=""
+all=""
+outdir="."
+sourcedir="."
+label=""
+timestamp=""
+
+builds=(
+ darwin/amd64
+ linux/386
+ windows/386
+)
+
+show_help() {
+ echo "Usage: $0 [-d <OUTPUTDIR>] [-l <LABEL>] [-t] -s <SOURCEDIR>"
+ echo " $0 -o <OS> -a <ARCH> [-d <DIRECTORY>] [-l <LABEL>] [-t] -s <SOURCEDIR>"
+ echo " $0 -A [-d <OUTPUTDIR>] [-l <LABEL>] [-t] -s <SOURCEDIR>"
+ echo " $0 -h"
+ echo
+ cat <<-EOH
+ -A Build for default OS/ARCH combinations
+ -a Set ARCH to build for
+ -d Set output directory
+ -h Show help
+ -l Set label text for including in filename
+ -o Set OS to build for
+ -t Set timestamp for including in filename
+ -s Source directory
+
+EOH
+
+ echo $OSVALUES | awk 'BEGIN{printf("Supported OS:\n")};{for(i=1;i<=NF;i++){printf("\t%s\n",$i)}}'
+ echo $ARCHVALUES | awk 'BEGIN{printf("Supported ARCH:\n")};{for(i=1;i<=NF;i++){printf("\t%s\n",$i)}}'
+ echo Default build:
+ for build in ${builds[@]} ; do
+ printf "\t%s\n" $build
+ done
+}
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -h|help)
+ show_help
+ exit 0
+ ;;
+ -d)
+ if [ $# -lt 2 ]; then
+ show_help
+ echo "Value for OUTPUTDIR must be provided"
+ exit 1
+ fi
+ outdir="$2"
+ shift 2
+ ;;
+ -s)
+ if [ $# -lt 2 ]; then
+ show_help
+ echo "Value for SOURCEDIR must be provided"
+ exit 1
+ fi
+ sourcedir="$2"
+ shift 2
+ ;;
+ -o)
+ if [ $# -lt 2 ]; then
+ show_help
+ echo "Value for OS must be provided"
+ exit 1
+ fi
+ os="$2"
+ shift 2
+ ;;
+ -a)
+ if [ $# -lt 2 ]; then
+ show_help
+ echo "Value for ARCH must be provided"
+ exit 1
+ fi
+ arch="$2"
+ shift 2
+ ;;
+ -A)
+ all="all"
+ shift 1
+ ;;
+ -l)
+ if [ $# -lt 2 ]; then
+ show_help
+ echo "Value for LABEL must be provided"
+ exit 1
+ fi
+ label=".$2"
+ shift 2
+ ;;
+ -t)
+ timestamp=`date +.%Y%m%d-%H%M%S`
+ shift
+ ;;
+ *)
+ show_help
+ echo "Unrecognised parameter: $1"
+ exit 1
+ ;;
+ esac
+done
+
+echo "Starting build.sh (brooklyn-client go build script)"
+
+#
+# Test if go is available
+#
+if ! command -v $GOBIN >/dev/null 2>&1 ; then
+ cat 1>&2 << \
+--MARKER--
+
+ERROR: Go language binaries not found (running "$GOBIN")
+
+The binaries for go v1.6 must be installed to build the brooklyn-client CLI.
+See golang.org for more information, or run maven with '-Dno-go-client' to skip.
+
+--MARKER--
+ exit 1
+fi
+
+GO_VERSION=`go version | awk '{print $3}'`
+GO_V=`echo $GO_VERSION | sed 's/^go1\.\([0-9][0-9]*\).*/\1/'`
+# test if not okay so error shows if regex above not matched
+if ! (( "$GO_V" >= 6 )) ; then
+ cat 1>&2 << \
+--MARKER--
+
+ERROR: Incompatible Go language version: $GO_VERSION
+
+Go version 1.6 or higher is required to build the brooklyn-client CLI.
+See golang.org for more information, or run maven with '-Dno-go-client' to skip.
+
+--MARKER--
+ exit 1
+fi
+
+
+if [ -n "$outdir" -a ! -d "$outdir" ]; then
+ show_help
+ echo "No such directory: $outdir"
+ exit 1
+fi
+
+# Set GOPATH to $outdir and link to source code.
+export GOPATH=${outdir}
+mkdir -p ${GOPATH}/src/${PROJECT%/*}
+[ -e ${GOPATH}/src/${PROJECT} ] || ln -s ${sourcedir} ${GOPATH}/src/${PROJECT}
+PATH=${GOPATH}/bin:${PATH}
+
+command -v $GLIDE >/dev/null 2>&1 || {
+ echo Installing $GLIDE
+ go get github.com/Masterminds/glide || { echo failed installing $GLIDE ; exit 1; }
+}
+
+command -v $GLIDE >/dev/null 2>&1 || {
+ echo "Command for resolving dependencies ($GLIDE) not found and could not be installed in $GOPATH"
+ exit 1
+}
+
+echo "Installing dependencies"
+$GLIDE install
+
+if [ -n "$all" -a \( -n "$os" -o -n "$arch" \) ]; then
+ show_help
+ echo "OS and ARCH must not be combined with ALL"
+ exit 1
+fi
+
+if [ \( -n "$os" -a -z "$arch" \) -o \( -z "$os" -a -n "$arch" \) ]; then
+ show_help
+ echo "OS and ARCH must be specified"
+ exit 1
+fi
+
+EXECUTABLE_DIR="$GOPATH/src/$CLI_PACKAGE"
+if [ -d ${EXECUTABLE_DIR} ]; then
+ cd ${EXECUTABLE_DIR}
+else
+ echo "Directory not found: ${EXECUTABLE_DIR}"
+ exit 2
+fi
+
+mkdir -p ${GOPATH}/bin
+
+# Disable use of C code modules (causes problems with cross-compiling)
+export CGO_ENABLED=0
+
+# build requested file
+function build_cli () {
+ local filepath=$1
+ mkdir -p ${filepath%/*}
+ $GOBIN build -ldflags "-s" -o $filepath $CLI_PACKAGE || return $?
+}
+
+# Do a build for one platorm, usage like: build_for_platform darwin/amd64
+function build_for_platform () {
+ local os=${1%/*}
+ local arch=${1#*/}
+ local BINARY=${BRNAME}
+ if [ "windows" = $os ] ; then
+ BINARY=${BINARY}.exe
+ fi
+ GOOS="$os" GOARCH="$arch" build_cli "${GOPATH}/bin/$os.$arch/${BINARY}${label}" || return $?
+}
+
+# Build as instructed
+if [ -z "$os" -a -z "$all" ]; then
+ echo "Building $BRNAME for native OS/ARCH"
+ build_cli "${GOPATH}/bin/${BRNAME}${label}${timestamp}" || exit $?
+elif [ -z "$all" ]; then
+ validos=`expr " $OSVALUES " : ".* $os "`
+ if [ "$validos" -eq 0 ]; then
+ show_help
+ echo "Unrecognised OS: $os"
+ exit 1
+ fi
+ validarch=`expr " $ARCHVALUES " : ".* $arch "`
+ if [ "$validarch" -eq 0 ]; then
+ show_help
+ echo "Unrecognised ARCH: $arch"
+ exit 1
+ fi
+ echo "Building $BRNAME for $os/$arch:"
+ build_for_platform $os/$arch || exit $?
+else
+ echo "Building $BRNAME for default OS/ARCH:"
+ for build in ${builds[@]}; do
+ echo " $build"
+ build_for_platform $build || exit $?
+ done
+fi
+
+echo
+echo Successfully built the following binaries:
+echo
+ls -lR ${GOPATH}/bin
+echo
+
+END_TIME=$(date +%s)
+echo "Completed build.sh (brooklyn-client go build script) in $(( $END_TIME - START_TIME ))s"
+
+exit 0
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/release/files/README
----------------------------------------------------------------------
diff --git a/cli/release/files/README b/cli/release/files/README
new file mode 100644
index 0000000..da1f0a0
--- /dev/null
+++ b/cli/release/files/README
@@ -0,0 +1,42 @@
+
+Apache Brooklyn Command Line Client
+===================================
+
+What is it?
+-----------
+
+A command line client, "br", for **[Apache Brooklyn](https://brooklyn.apache.org)**.
+
+With this tool you can deploy and manage applications on a running Brooklyn server.
+
+This file gives a brief summary of how to use the Brooklyn CLI client tool.
+More complete documentation is available **[on the Apache Brooklyn website](https://brooklyn.apache.org/v/latest/ops/cli/cli-ref-guide.html).
+
+
+License
+-------
+
+Please see the file [LICENSE](LICENSE).
+
+
+Getting Started
+---------------
+
+Find the binary which is right for your platform.
+You'll typically find it in a sub-directory here.
+(Note that "Darwin" is a technical name for "Mac OS X".)
+
+Add it to your path or alias it with `br`.
+
+Then log in to your Brooklyn instance with:
+
+ $ br login URL [USER PASSWORD]
+
+See the help command for info on all commands:
+
+ $ br help
+
+For help on individual commands:
+
+ $ br help COMMAND
+
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/release/license/files/LICENSE
----------------------------------------------------------------------
diff --git a/cli/release/license/files/LICENSE b/cli/release/license/files/LICENSE
new file mode 100644
index 0000000..9764158
--- /dev/null
+++ b/cli/release/license/files/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/release/license/source-inclusions.yaml
----------------------------------------------------------------------
diff --git a/cli/release/license/source-inclusions.yaml b/cli/release/license/source-inclusions.yaml
new file mode 100644
index 0000000..dddc9dc
--- /dev/null
+++ b/cli/release/license/source-inclusions.yaml
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+
+# extras file for org.heneveld.license-audit-maven-plugin
+# listing projects from which *source* files are included
+
+- id: github.com/urfave/cli
+- id: golang.org/x/crypto/ssh
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/scope/scope.go
----------------------------------------------------------------------
diff --git a/cli/scope/scope.go b/cli/scope/scope.go
new file mode 100644
index 0000000..9332c4a
--- /dev/null
+++ b/cli/scope/scope.go
@@ -0,0 +1,137 @@
+/*
+ * 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 scope
+
+import (
+ "strings"
+)
+
+type Scope struct {
+ Application string
+ Entity string
+ Effector string
+ Config string
+ Activity string
+}
+
+func (scope Scope) String() string {
+ return strings.Join([]string{
+ "{Application: ", scope.Application,
+ ", Entity: ", scope.Entity,
+ ", Effector: ", scope.Effector,
+ ", Config: ", scope.Config,
+ ", Activity: ", scope.Activity,
+ "}",
+ }, "")
+}
+
+func application(scope *Scope, id string) {
+ scope.Application = id
+}
+
+func entity(scope *Scope, id string) {
+ scope.Entity = id
+}
+
+func effector(scope *Scope, id string) {
+ scope.Effector = id
+}
+
+func config(scope *Scope, id string) {
+ scope.Config = id
+}
+
+func activity(scope *Scope, id string) {
+ scope.Activity = id
+}
+
+var scopeSpecifier = map[string]func(scope *Scope, id string){
+ "application": application,
+ "app": application,
+ "a": application,
+ "entity": entity,
+ "ent": entity,
+ "e": entity,
+ "effector": effector,
+ "eff": effector,
+ "f": effector,
+ "config": config,
+ "conf": config,
+ "con": config,
+ "c": config,
+ "activity": activity,
+ "act": activity,
+ "v": activity,
+}
+
+// Scopes the arguments.
+// Assumes the arguments are a copy of the program args, including the first member that defines the program name.
+// Removes the scope arguments from the array and applies them to a scope object.
+// Returns the remaining arguments with the program name restored to first argument.
+// For example with input
+// br application 1 entity 2 doSomething
+// the function will return ([]string{"br", "doSomething"}, Scope{Application:1, Entity:2})
+func ScopeArguments(args []string) ([]string, Scope) {
+ scope := Scope{}
+
+ if len(args) < 2 {
+ return args, scope
+ }
+
+ command := args[0]
+ args = args[1:]
+
+ args = defineScope(args, &scope)
+
+ args = prepend(command, args)
+
+ return args, scope
+}
+
+func defineScope(args []string, scope *Scope) []string {
+
+ allScopesFound := false
+ for !allScopesFound && len(args) > 2 && args[1][0] != '-' {
+ if setAppropriateScope, nameOfAScope := scopeSpecifier[args[0]]; nameOfAScope {
+ setAppropriateScope(scope, args[1])
+ args = args[2:]
+ } else {
+ allScopesFound = true
+ }
+ }
+
+ setDefaultEntityIfRequired(scope)
+
+ return args
+}
+
+func setDefaultEntityIfRequired(scope *Scope) {
+ if "" == scope.Entity {
+ scope.Entity = scope.Application
+ }
+}
+
+func prepend(v string, args []string) []string {
+ result := make([]string, len(args)+1)
+ result[0] = v
+ for i, a := range args {
+ result[i+1] = a
+ }
+ return result
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/terminal/table.go
----------------------------------------------------------------------
diff --git a/cli/terminal/table.go b/cli/terminal/table.go
new file mode 100644
index 0000000..c163318
--- /dev/null
+++ b/cli/terminal/table.go
@@ -0,0 +1,102 @@
+/*
+ * 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 terminal
+
+import (
+ "fmt"
+ "strings"
+ "unicode/utf8"
+)
+
+type Table interface {
+ Add(row ...string)
+ Print()
+}
+
+type PrintableTable struct {
+ headers []string
+ headerPrinted bool
+ maxSizes []int
+ rows [][]string
+}
+
+func NewTable(headers []string) Table {
+ return &PrintableTable{
+ headers: headers,
+ maxSizes: make([]int, len(headers)),
+ }
+}
+
+func (t *PrintableTable) Add(row ...string) {
+ t.rows = append(t.rows, row)
+}
+
+func (t *PrintableTable) Print() {
+ for _, row := range append(t.rows, t.headers) {
+ t.calculateMaxSize(row)
+ }
+
+ if t.headerPrinted == false {
+ t.printHeader()
+ t.headerPrinted = true
+ }
+
+ for _, line := range t.rows {
+ t.printRow(line)
+ }
+
+ t.rows = [][]string{}
+}
+
+func (t *PrintableTable) calculateMaxSize(row []string) {
+ for index, value := range row {
+ cellLength := utf8.RuneCountInString(value)
+ if t.maxSizes[index] < cellLength {
+ t.maxSizes[index] = cellLength
+ }
+ }
+}
+
+func (t *PrintableTable) printHeader() {
+ output := ""
+ for col, value := range t.headers {
+ output = output + t.cellValue(col, value)
+ }
+ fmt.Println(output)
+}
+
+func (t *PrintableTable) printRow(row []string) {
+ output := ""
+ for columnIndex, value := range row {
+ if columnIndex == 0 {
+ value = value
+ }
+
+ output = output + t.cellValue(columnIndex, value)
+ }
+ fmt.Printf("%s\n", output)
+}
+
+func (t *PrintableTable) cellValue(col int, value string) string {
+ padding := ""
+ if col < len(t.headers)-1 {
+ padding = strings.Repeat(" ", t.maxSizes[col]-utf8.RuneCountInString(value))
+ }
+ return fmt.Sprintf("%s%s ", value, padding)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/test/test.sh
----------------------------------------------------------------------
diff --git a/cli/test/test.sh b/cli/test/test.sh
new file mode 100644
index 0000000..7f86538
--- /dev/null
+++ b/cli/test/test.sh
@@ -0,0 +1,226 @@
+#!/usr/bin/env bash
+# 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.
+
+declare -a FAILS
+
+export BRCLI_HOME=/tmp
+trap cleanup EXIT
+
+
+function usage() {
+ echo "Usage: $0 <brooklyn_url> [ <user> <password> ]"
+ exit 0
+}
+
+
+function cleanup() {
+ rm -f $BRCLI_HOME/.brooklyn_cli
+}
+
+function title() {
+ echo "*************************************************************************"
+ echo " ${FUNCNAME[1]}"
+ echo "*************************************************************************"
+}
+
+function fail() {
+ local code=$?
+ local message="$*"
+ FAILS[${#FAILS[*]}]="${FUNCNAME[1]}: (${code}) ${message}"
+}
+
+function report() {
+ if [ 0 -ne ${#FAILS[*]} ] ; then
+ echo " ${#FAILS[*]} Test failures" 1>&2
+ else
+ echo All tests succeeded
+ fi
+ local n=0
+ while [ $n -lt ${#FAILS[*]} ] ; do
+ echo ${FAILS[$N]} 1>&2
+ n=$(( $n + 1 ))
+ done
+}
+
+
+function isAppStatus() {
+ local appname=$1
+ local status=$2
+ br apps | grep "${appname}" | grep ${status} > /dev/null
+}
+
+function isEntityStatus() {
+ local appname=$1
+ local entity=$2
+ local status=$3
+
+ br app "${appname}" ent "${entity}" | grep ${status} > /dev/null
+}
+
+function waitForCommand() {
+ local N=300 # 5 minutes
+ while [ $N -gt 0 ] && ! "$@" ; do
+ sleep 1
+ N=$(($N - 1))
+ done
+ if [ $N -eq 0 ] ; then
+ return 1
+ fi
+ return 0
+}
+
+
+
+function brIsDefined() {
+ type br > /dev/null 2>&1
+}
+
+
+#
+# TESTS
+#
+
+function shouldLogin() {
+ title
+ br login $1 $2 $3 || fail
+}
+
+
+
+function shouldDeployTomcat() {
+ title
+
+ br deploy test_app.yaml
+
+ waitForCommand isAppStatus "Test Tomcat" RUNNING || fail
+}
+
+function shouldRenameApp() {
+ title
+ local appname=$1
+ local rename=$2
+
+ br app "${appname}" rename "${rename}"
+
+ br apps | grep "${rename}" | grep RUNNING || fail
+}
+
+function shouldGetAppConfig() {
+ title
+ local appname=$1
+ br app "${appname}" config | grep brooklyn.wrapper_app | grep true || fail
+}
+
+function shouldGetTomcatServerEntity() {
+ title
+ local appname=$1
+
+ br app "${appname}" entity | grep TomcatServer || fail
+}
+
+
+function shouldRenameTomcatServerEntity() {
+ title
+ local appname=$1
+ local rename=$2
+
+ br app "${appname}" entity "Tomcat Server" rename "${rename}"
+ br app "${appname}" entity "${rename}" | grep TomcatServer || fail
+}
+
+function shouldStopEntity() {
+ title
+ local appname=$1
+ local entityname=$2
+
+ br app "${appname}" ent "${entityname}" stop
+
+ waitForCommand isEntityStatus "${appname}" "${entityname}" STOPPED || fail; return
+}
+
+function shouldRestartEntity() {
+ title
+ local appname=$1
+ local entityname=$2
+
+ br app "${appname}" restart "${entityname}"
+
+ waitForCommand isEntityStatus "${appname}" "${entityname}" RUNNING || fail; return
+}
+
+function shouldStartEntity() {
+ title
+ local appname=$1
+ local entityname=$2
+
+ br app "${appname}" start "${entityname}"
+
+ waitForCommand isEntityStatus "${appname}" "${entityname}" RUNNING || fail; return
+}
+
+
+function runAllTests() {
+
+ local brooklyn_url=${1}
+ local user=${2}
+ local password=${3}
+
+ shouldLogin ${brooklyn_url} ${user} ${password}
+ shouldDeployTomcat
+ shouldRenameApp "Test Tomcat" mytest
+ shouldGetAppConfig mytest
+ shouldGetTomcatServerEntity mytest
+ shouldRenameTomcatServerEntity mytest myserver
+ shouldStopEntity mytest myserver
+ shouldStartEntity mytest myserver
+ shouldRestartEntity mytest myserver
+
+
+ #... TODO add more tests here
+}
+
+#
+# main function
+#
+function main() {
+
+ [ $1 ] || usage
+
+ local brooklyn_url=${1}
+ local user=${2}
+ local password=${3}
+
+ brIsDefined || {
+ >&2 echo br is not defined
+ exit 1
+ }
+
+ runAllTests ${brooklyn_url} ${user} ${password}
+
+ # If there are test failures we leave the application running, in case it helps determine what failed.
+ if [ 0 -eq ${#FAILS[*]} ] ; then
+ echo Stopping test application
+ br app mytest stop
+ fi
+
+ report
+
+}
+
+main $@
+exit ${#FAILS[*]}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/test/test_app.yaml
----------------------------------------------------------------------
diff --git a/cli/test/test_app.yaml b/cli/test/test_app.yaml
new file mode 100644
index 0000000..f5e9abe
--- /dev/null
+++ b/cli/test/test_app.yaml
@@ -0,0 +1,22 @@
+# 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.
+
+name: Test Tomcat
+location:
+ replaceMeWithYourLocation
+services:
+ - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/command/command.go
----------------------------------------------------------------------
diff --git a/command/command.go b/command/command.go
deleted file mode 100644
index 1a16282..0000000
--- a/command/command.go
+++ /dev/null
@@ -1,30 +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 command
-
-import (
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type Command interface {
- Metadata() command_metadata.CommandMetadata
- Run(scope scope.Scope, context *cli.Context)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/command/supercommand.go
----------------------------------------------------------------------
diff --git a/command/supercommand.go b/command/supercommand.go
deleted file mode 100644
index 82a5856..0000000
--- a/command/supercommand.go
+++ /dev/null
@@ -1,30 +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 command
-
-// A command with further (sub) commands, like 'git remote', with its 'git remote add' etc.
-type SuperCommand interface {
- Command
-
- // Get the sub command wih the given name
- SubCommand(name string) Command
-
- // Get the names of all subcommands
- SubCommandNames() []string
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/command_factory/factory.go
----------------------------------------------------------------------
diff --git a/command_factory/factory.go b/command_factory/factory.go
deleted file mode 100644
index 7a46eb9..0000000
--- a/command_factory/factory.go
+++ /dev/null
@@ -1,141 +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 command_factory
-
-import (
- "errors"
- "github.com/apache/brooklyn-client/command"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/commands"
- "github.com/apache/brooklyn-client/io"
- "github.com/apache/brooklyn-client/net"
- "sort"
- "strings"
-)
-
-type Factory interface {
- GetByCmdName(cmdName string) (cmd command.Command, err error)
- GetBySubCmdName(cmdName string, subCmdName string) (cmd command.Command, err error)
- CommandMetadatas() []command_metadata.CommandMetadata
-}
-
-type concreteFactory struct {
- cmdsByName map[string]command.Command
- subCommands map[string]map[string]command.Command
-}
-
-func NewFactory(network *net.Network, config *io.Config) (factory concreteFactory) {
- factory.cmdsByName = make(map[string]command.Command)
- factory.subCommands = make(map[string]map[string]command.Command)
-
- factory.simpleCommand(commands.NewAccess(network))
- //factory.command(commands.NewActivities(network))
- factory.simpleCommand(commands.NewActivity(network))
- factory.simpleCommand(commands.NewActivityStreamEnv(network))
- factory.simpleCommand(commands.NewActivityStreamStderr(network))
- factory.simpleCommand(commands.NewActivityStreamStdin(network))
- factory.simpleCommand(commands.NewActivityStreamStdout(network))
- factory.simpleCommand(commands.NewAddCatalog(network))
- factory.simpleCommand(commands.NewAddChildren(network))
- factory.simpleCommand(commands.NewApplication(network))
- //factory.simpleCommand(commands.NewApplications(network))
- factory.simpleCommand(commands.NewCatalog(network))
- factory.simpleCommand(commands.NewConfig(network))
- factory.simpleCommand(commands.NewDeploy(network))
- factory.simpleCommand(commands.NewDelete(network))
- factory.simpleCommand(commands.NewDestroyPolicy(network))
- factory.simpleCommand(commands.NewEffector(network))
- factory.simpleCommand(commands.NewEntity(network))
- factory.simpleCommand(commands.NewInvoke(network))
- factory.simpleCommand(commands.NewInvokeRestart(network))
- factory.simpleCommand(commands.NewInvokeStart(network))
- factory.simpleCommand(commands.NewInvokeStop(network))
- // NewList below is not used but we retain the code as an example of how to do a super command.
- // factory.superCommand(commands.NewList(network))
- factory.simpleCommand(commands.NewLocations(network))
- factory.simpleCommand(commands.NewLogin(network, config))
- factory.simpleCommand(commands.NewPolicy(network))
- factory.simpleCommand(commands.NewRename(network))
- factory.simpleCommand(commands.NewSensor(network))
- factory.simpleCommand(commands.NewSetConfig(network))
- factory.simpleCommand(commands.NewSpec(network))
- factory.simpleCommand(commands.NewStartPolicy(network))
- factory.simpleCommand(commands.NewStopPolicy(network))
- factory.simpleCommand(commands.NewTree(network))
- factory.simpleCommand(commands.NewVersion(network))
-
- return factory
-}
-
-func (factory *concreteFactory) simpleCommand(cmd command.Command) {
- factory.cmdsByName[cmd.Metadata().Name] = cmd
-}
-
-func (factory *concreteFactory) superCommand(cmd command.SuperCommand) {
-
- factory.simpleCommand(cmd)
-
- if nil == factory.subCommands[cmd.Metadata().Name] {
- factory.subCommands[cmd.Metadata().Name] = make(map[string]command.Command)
- }
-
- for _, sub := range cmd.SubCommandNames() {
- factory.subCommands[cmd.Metadata().Name][sub] = cmd.SubCommand(sub)
- }
-}
-
-func (f concreteFactory) GetByCmdName(cmdName string) (cmd command.Command, err error) {
- cmd, found := f.cmdsByName[cmdName]
- if !found {
- for _, c := range f.cmdsByName {
- if c.Metadata().ShortName == cmdName {
- return c, nil
- }
- }
-
- err = errors.New(strings.Join([]string{"Command not found:", cmdName}, " "))
- }
- return
-}
-
-func (f concreteFactory) GetBySubCmdName(cmdName string, subCmdName string) (cmd command.Command, err error) {
-
- _, hasPrimary := f.subCommands[cmdName]
- if hasPrimary {
- cmd, found := f.subCommands[cmdName][subCmdName]
- if found {
- return cmd, nil
- }
- }
- return cmd, errors.New(strings.Join([]string{"Command not found:", cmdName, subCmdName}, " "))
-}
-
-func (factory concreteFactory) CommandMetadatas() (commands []command_metadata.CommandMetadata) {
- keys := make([]string, 0, len(factory.cmdsByName))
- for key := range factory.cmdsByName {
- keys = append(keys, key)
- }
- sort.Strings(keys)
-
- for _, key := range keys {
- command := factory.cmdsByName[key]
- commands = append(commands, command.Metadata())
- }
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/command_metadata/command_metadata.go
----------------------------------------------------------------------
diff --git a/command_metadata/command_metadata.go b/command_metadata/command_metadata.go
deleted file mode 100644
index eac321f..0000000
--- a/command_metadata/command_metadata.go
+++ /dev/null
@@ -1,33 +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 command_metadata
-
-import "github.com/urfave/cli"
-
-type CommandMetadata struct {
- Name string
- Aliases []string
- ShortName string
- Usage string
- Description string
- Flags []cli.Flag
- SkipFlagParsing bool
- TotalArgs int //Optional: number of required arguments to skip for flag verification
- Operands []CommandMetadata
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/command_runner/runner.go
----------------------------------------------------------------------
diff --git a/command_runner/runner.go b/command_runner/runner.go
deleted file mode 100644
index c123b5f..0000000
--- a/command_runner/runner.go
+++ /dev/null
@@ -1,61 +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 command_runner
-
-import (
- "github.com/apache/brooklyn-client/command_factory"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type Runner interface {
- RunCmdByName(cmdName string, c *cli.Context) (err error)
- RunSubCmdByName(cmdName string, subCommand string, c *cli.Context) (err error)
-}
-
-type ConcreteRunner struct {
- cmdFactory command_factory.Factory
- scope scope.Scope
-}
-
-func NewRunner(scope scope.Scope, cmdFactory command_factory.Factory) (runner ConcreteRunner) {
- runner.cmdFactory = cmdFactory
- runner.scope = scope
- return
-}
-
-func (runner ConcreteRunner) RunCmdByName(cmdName string, c *cli.Context) error {
- cmd, err := runner.cmdFactory.GetByCmdName(cmdName)
- if nil != err {
- return err
- }
-
- cmd.Run(runner.scope, c)
- return nil
-}
-
-func (runner ConcreteRunner) RunSubCmdByName(cmdName string, subCommand string, c *cli.Context) error {
- cmd, err := runner.cmdFactory.GetBySubCmdName(cmdName, subCommand)
- if nil != err {
- return err
- }
-
- cmd.Run(runner.scope, c)
- return nil
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/access.go
----------------------------------------------------------------------
diff --git a/commands/access.go b/commands/access.go
deleted file mode 100644
index 87e26cd..0000000
--- a/commands/access.go
+++ /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.
- */
-package commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/access_control"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type Access struct {
- network *net.Network
-}
-
-func NewAccess(network *net.Network) (cmd *Access) {
- cmd = new(Access)
- cmd.network = network
- return
-}
-
-func (cmd *Access) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "access",
- Description: "Show access control",
- Usage: "BROOKLYN_NAME access",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Access) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- access, err := access_control.Access(cmd.network)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println("Location Provisioning Allowed:", access.LocationProvisioningAllowed)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/activity-stream.go
----------------------------------------------------------------------
diff --git a/commands/activity-stream.go b/commands/activity-stream.go
deleted file mode 100644
index eceadc4..0000000
--- a/commands/activity-stream.go
+++ /dev/null
@@ -1,149 +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 commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/activities"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type ActivityStreamEnv struct {
- network *net.Network
-}
-
-type ActivityStreamStderr struct {
- network *net.Network
-}
-
-type ActivityStreamStdin struct {
- network *net.Network
-}
-
-type ActivityStreamStdout struct {
- network *net.Network
-}
-
-func NewActivityStreamEnv(network *net.Network) (cmd *ActivityStreamEnv) {
- cmd = new(ActivityStreamEnv)
- cmd.network = network
- return
-}
-
-func NewActivityStreamStderr(network *net.Network) (cmd *ActivityStreamStderr) {
- cmd = new(ActivityStreamStderr)
- cmd.network = network
- return
-}
-
-func NewActivityStreamStdin(network *net.Network) (cmd *ActivityStreamStdin) {
- cmd = new(ActivityStreamStdin)
- cmd.network = network
- return
-}
-
-func NewActivityStreamStdout(network *net.Network) (cmd *ActivityStreamStdout) {
- cmd = new(ActivityStreamStdout)
- cmd.network = network
- return
-}
-
-func (cmd *ActivityStreamEnv) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "env",
- Description: "Show the ENV stream for a given activity",
- Usage: "BROOKLYN_NAME ACTIVITY-SCOPE env",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *ActivityStreamStderr) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "stderr",
- Description: "Show the STDERR stream for a given activity",
- Usage: "BROOKLYN_NAME ACTIVITY-SCOPE stderr",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *ActivityStreamStdin) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "stdin",
- Description: "Show the STDIN stream for a given activity",
- Usage: "BROOKLYN_NAME ACTIVITY-SCOPE ] stdin",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *ActivityStreamStdout) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "stdout",
- Description: "Show the STDOUT stream for a given activity",
- Usage: "BROOKLYN_NAME ACTIVITY-SCOPE stdout",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *ActivityStreamEnv) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "env")
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(activityStream)
-}
-
-func (cmd *ActivityStreamStderr) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "stderr")
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(activityStream)
-}
-
-func (cmd *ActivityStreamStdin) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "stdin")
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(activityStream)
-}
-
-func (cmd *ActivityStreamStdout) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "stdout")
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(activityStream)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/activity.go
----------------------------------------------------------------------
diff --git a/commands/activity.go b/commands/activity.go
deleted file mode 100644
index d748c1a..0000000
--- a/commands/activity.go
+++ /dev/null
@@ -1,162 +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 commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/activities"
- "github.com/apache/brooklyn-client/api/entities"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/models"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/apache/brooklyn-client/terminal"
- "github.com/urfave/cli"
- "sort"
- "strconv"
- "strings"
- "time"
-)
-
-type Activity struct {
- network *net.Network
-}
-
-func NewActivity(network *net.Network) (cmd *Activity) {
- cmd = new(Activity)
- cmd.network = network
- return
-}
-
-func (cmd *Activity) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "activity",
- Aliases: []string{"activities", "act", "acts"},
- Description: "Show the activity for an application / entity",
- Usage: "BROOKLYN_NAME SCOPE activity [ ACTIVITYID]",
- Flags: []cli.Flag{
- cli.StringSliceFlag{
- Name: "children, c",
- Usage: "List children of the activity",
- },
- },
- }
-}
-
-func (cmd *Activity) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- if c.NumFlags() > 0 && c.FlagNames()[0] == "children" {
- cmd.listchildren(c.StringSlice("children")[0])
- } else {
- if c.Args().Present() {
- cmd.show(c.Args().First())
- } else {
- if scope.Activity == "" {
- cmd.list(scope.Application, scope.Entity)
- } else {
- cmd.listchildren(scope.Activity)
- }
- }
- }
-}
-
-func (cmd *Activity) show(activityId string) {
- activity, err := activities.Activity(cmd.network, activityId)
- if nil != err {
- error_handler.ErrorExit(err)
- }
-
- table := terminal.NewTable([]string{"Id:", activity.Id})
- table.Add("DisplayName:", activity.DisplayName)
- table.Add("Description:", activity.Description)
- table.Add("EntityId:", activity.EntityId)
- table.Add("EntityDisplayName:", activity.EntityDisplayName)
- table.Add("Submitted:", time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate))
- table.Add("Started:", time.Unix(activity.StartTimeUtc/1000, 0).Format(time.UnixDate))
- table.Add("Ended:", time.Unix(activity.EndTimeUtc/1000, 0).Format(time.UnixDate))
- table.Add("CurrentStatus:", activity.CurrentStatus)
- table.Add("IsError:", strconv.FormatBool(activity.IsError))
- table.Add("IsCancelled:", strconv.FormatBool(activity.IsCancelled))
- table.Add("SubmittedByTask:", activity.SubmittedByTask.Metadata.Id)
- if activity.Streams["stdin"].Metadata.Size > 0 ||
- activity.Streams["stdout"].Metadata.Size > 0 ||
- activity.Streams["stderr"].Metadata.Size > 0 ||
- activity.Streams["env"].Metadata.Size > 0 {
- table.Add("Streams:", fmt.Sprintf("stdin: %d, stdout: %d, stderr: %d, env %d",
- activity.Streams["stdin"].Metadata.Size,
- activity.Streams["stdout"].Metadata.Size,
- activity.Streams["stderr"].Metadata.Size,
- activity.Streams["env"].Metadata.Size))
- } else {
- table.Add("Streams:", "")
- }
- table.Add("DetailedStatus:", fmt.Sprintf("\"%s\"", activity.DetailedStatus))
- table.Print()
-}
-
-func (cmd *Activity) list(application, entity string) {
- activityList, err := entities.GetActivities(cmd.network, application, entity)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Id", "Task", "Submitted", "Status", "Streams"})
- for _, activity := range activityList {
- table.Add(activity.Id,
- truncate(activity.DisplayName),
- time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate), truncate(activity.CurrentStatus),
- streams(activity))
- }
- table.Print()
-}
-
-func (cmd *Activity) listchildren(activity string) {
- activityList, err := activities.ActivityChildren(cmd.network, activity)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Id", "Task", "Submitted", "Status", "Streams"})
- for _, activity := range activityList {
- table.Add(activity.Id,
- truncate(activity.DisplayName),
- time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate), truncate(activity.CurrentStatus),
- streams(activity))
- }
- table.Print()
-}
-
-func streams(act models.TaskSummary) string {
- names := make([]string, 0)
- for name, _ := range act.Streams {
- names = append(names, name)
- }
- sort.Strings(names)
- return strings.Join(names, ",")
-}
-
-const truncLimit = 40
-
-func truncate(text string) string {
- if len(text) < truncLimit {
- return text
- }
- return text[0:(truncLimit-3)] + "..."
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/add-catalog.go
----------------------------------------------------------------------
diff --git a/commands/add-catalog.go b/commands/add-catalog.go
deleted file mode 100644
index b161f8b..0000000
--- a/commands/add-catalog.go
+++ /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.
- */
-package commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/catalog"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type AddCatalog struct {
- network *net.Network
-}
-
-func NewAddCatalog(network *net.Network) (cmd *AddCatalog) {
- cmd = new(AddCatalog)
- cmd.network = network
- return
-}
-
-func (cmd *AddCatalog) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "add-catalog",
- Description: "* Add a new catalog item from the supplied YAML (a file or http URL)",
- Usage: "BROOKLYN_NAME add-catalog ( FILEPATH | URL )",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *AddCatalog) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- create, err := catalog.AddCatalog(cmd.network, c.Args().First())
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(create)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/add-children.go
----------------------------------------------------------------------
diff --git a/commands/add-children.go b/commands/add-children.go
deleted file mode 100644
index d05a114..0000000
--- a/commands/add-children.go
+++ /dev/null
@@ -1,63 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/api/entities"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/apache/brooklyn-client/terminal"
- "github.com/urfave/cli"
- "time"
-)
-
-type AddChildren struct {
- network *net.Network
-}
-
-func NewAddChildren(network *net.Network) (cmd *AddChildren) {
- cmd = new(AddChildren)
- cmd.network = network
- return
-}
-
-func (cmd *AddChildren) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "add-children",
- Description: "* Add a child or children to this entity from the supplied YAML",
- Usage: "BROOKLYN_NAME SCOPE add-children ( FILEPATH | URL )",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *AddChildren) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- activity, err := entities.AddChildren(cmd.network, scope.Application, scope.Entity, c.Args().First())
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Id", "Task", "Submitted", "Status"})
- table.Add(activity.Id, activity.DisplayName, time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate), activity.CurrentStatus)
-
- table.Print()
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/add-location.go
----------------------------------------------------------------------
diff --git a/commands/add-location.go b/commands/add-location.go
deleted file mode 100644
index 32c2db0..0000000
--- a/commands/add-location.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type AddLocation struct {
- network *net.Network
-}
-
-func NewAddLocation(network *net.Network) (cmd *AddLocation) {
- cmd = new(AddLocation)
- cmd.network = network
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/add-policy.go
----------------------------------------------------------------------
diff --git a/commands/add-policy.go b/commands/add-policy.go
deleted file mode 100644
index 35de8c4..0000000
--- a/commands/add-policy.go
+++ /dev/null
@@ -1,50 +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 commands
-
-import (
- "github.com/urfave/cli"
- //"github.com/apache/brooklyn-client/api/entity_policies"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
-)
-
-type AddPolicy struct {
- network *net.Network
-}
-
-func NewAddPolicy(network *net.Network) (cmd *AddPolicy) {
- cmd = new(AddPolicy)
- cmd.network = network
- return
-}
-
-func (cmd *AddPolicy) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "add-policy",
- Description: "Add a new policy",
- Usage: "BROOKLYN_NAME [ SCOPE ] add-policy APPLICATION ENTITY POLICY_TYPE",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *AddPolicy) Run(scope scope.Scope, c *cli.Context) {
- // Todo
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/application.go
----------------------------------------------------------------------
diff --git a/commands/application.go b/commands/application.go
deleted file mode 100644
index c321227..0000000
--- a/commands/application.go
+++ /dev/null
@@ -1,111 +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 commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/application"
- "github.com/apache/brooklyn-client/api/entities"
- "github.com/apache/brooklyn-client/api/entity_sensors"
- "github.com/apache/brooklyn-client/api/locations"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/apache/brooklyn-client/terminal"
- "github.com/urfave/cli"
- "strings"
-)
-
-type Application struct {
- network *net.Network
-}
-
-func NewApplication(network *net.Network) (cmd *Application) {
- cmd = new(Application)
- cmd.network = network
- return
-}
-
-func (cmd *Application) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "application",
- Aliases: []string{"applications", "app", "apps"},
- Description: "Show the status and location of running applications",
- Usage: "BROOKLYN_NAME application [APP]",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Application) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- if c.Args().Present() {
- cmd.show(c.Args().First())
- } else {
- cmd.list()
- }
-}
-
-const serviceIsUpStr = "service.isUp"
-
-func (cmd *Application) show(appName string) {
- application, err := application.Application(cmd.network, appName)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- entity, err := entities.GetEntity(cmd.network, appName, appName)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- state, err := entity_sensors.CurrentState(cmd.network, appName, appName)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- location, err := locations.GetLocation(cmd.network, application.Spec.Locations[0])
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Id:", application.Id})
- table.Add("Name:", application.Spec.Name)
- table.Add("Status:", string(application.Status))
- if serviceUp, ok := state[serviceIsUpStr]; ok {
- table.Add("ServiceUp:", fmt.Sprintf("%v", serviceUp))
- }
- table.Add("Type:", application.Spec.Type)
- table.Add("CatalogItemId:", entity.CatalogItemId)
- table.Add("LocationId:", strings.Join(application.Spec.Locations, ", "))
- table.Add("LocationName:", location.Name)
- table.Add("LocationSpec:", location.Spec)
- table.Add("LocationType:", location.Type)
- table.Print()
-}
-
-func (cmd *Application) list() {
- applications, err := application.Applications(cmd.network)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Id", "Name", "Status", "Location"})
- for _, app := range applications {
- table.Add(app.Id, app.Spec.Name, string(app.Status), strings.Join(app.Spec.Locations, ", "))
- }
- table.Print()
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/catalog-applications.go
----------------------------------------------------------------------
diff --git a/commands/catalog-applications.go b/commands/catalog-applications.go
deleted file mode 100644
index 19a4373..0000000
--- a/commands/catalog-applications.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type CatalogApplication struct {
- network *net.Network
-}
-
-func NewCatalogApplication(network *net.Network) (cmd *CatalogApplication) {
- cmd = new(CatalogApplication)
- cmd.network = network
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/catalog-entities.go
----------------------------------------------------------------------
diff --git a/commands/catalog-entities.go b/commands/catalog-entities.go
deleted file mode 100644
index dbec760..0000000
--- a/commands/catalog-entities.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type CatalogEntities struct {
- network *net.Network
-}
-
-func NewCatalogEntities(network *net.Network) (cmd *CatalogEntities) {
- cmd = new(CatalogEntities)
- cmd.network = network
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/catalog-entity.go
----------------------------------------------------------------------
diff --git a/commands/catalog-entity.go b/commands/catalog-entity.go
deleted file mode 100644
index 23cc295..0000000
--- a/commands/catalog-entity.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type CatalogEntity struct {
- network *net.Network
-}
-
-func NewCatalogEntity(network *net.Network) (cmd *CatalogEntity) {
- cmd = new(CatalogEntity)
- cmd.network = network
- return
-}
[04/10] brooklyn-client git commit: move rest-client to
brooklyn-client
Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/catalog-location.go
----------------------------------------------------------------------
diff --git a/commands/catalog-location.go b/commands/catalog-location.go
deleted file mode 100644
index 40babdd..0000000
--- a/commands/catalog-location.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type CatalogLocation struct {
- network *net.Network
-}
-
-func NewCatalogLocation(network *net.Network) (cmd *CatalogLocation) {
- cmd = new(CatalogLocation)
- cmd.network = network
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/catalog-locations.go
----------------------------------------------------------------------
diff --git a/commands/catalog-locations.go b/commands/catalog-locations.go
deleted file mode 100644
index e1791e8..0000000
--- a/commands/catalog-locations.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type CatalogLocations struct {
- network *net.Network
-}
-
-func NewCatalogLocations(network *net.Network) (cmd *CatalogLocations) {
- cmd = new(CatalogLocations)
- cmd.network = network
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/catalog-policies.go
----------------------------------------------------------------------
diff --git a/commands/catalog-policies.go b/commands/catalog-policies.go
deleted file mode 100644
index 3e245db..0000000
--- a/commands/catalog-policies.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type CatalogPolicies struct {
- network *net.Network
-}
-
-func NewCatalogPolicies(network *net.Network) (cmd *CatalogPolicies) {
- cmd = new(CatalogPolicies)
- cmd.network = network
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/catalog-policy.go
----------------------------------------------------------------------
diff --git a/commands/catalog-policy.go b/commands/catalog-policy.go
deleted file mode 100644
index 82e8a95..0000000
--- a/commands/catalog-policy.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type CatalogPolicy struct {
- network *net.Network
-}
-
-func NewCatalogPolicy(network *net.Network) (cmd *CatalogPolicy) {
- cmd = new(CatalogPolicy)
- cmd.network = network
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/catalog.go
----------------------------------------------------------------------
diff --git a/commands/catalog.go b/commands/catalog.go
deleted file mode 100644
index fd1d8ad..0000000
--- a/commands/catalog.go
+++ /dev/null
@@ -1,63 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/api/catalog"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/apache/brooklyn-client/terminal"
- "github.com/urfave/cli"
-)
-
-type Catalog struct {
- network *net.Network
-}
-
-func NewCatalog(network *net.Network) (cmd *Catalog) {
- cmd = new(Catalog)
- cmd.network = network
- return
-}
-
-func (cmd *Catalog) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "catalog",
- Description: "* List the available catalog applications",
- Usage: "BROOKLYN_NAME catalog",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Catalog) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- catalog, err := catalog.Catalog(cmd.network)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Id", "Name", "Description"})
- for _, app := range catalog {
- table.Add(app.Id, app.Name, app.Description)
- }
- table.Print()
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/config.go
----------------------------------------------------------------------
diff --git a/commands/config.go b/commands/config.go
deleted file mode 100644
index 33d9cba..0000000
--- a/commands/config.go
+++ /dev/null
@@ -1,78 +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 commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/entity_config"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/apache/brooklyn-client/terminal"
- "github.com/urfave/cli"
-)
-
-type Config struct {
- network *net.Network
-}
-
-func NewConfig(network *net.Network) (cmd *Config) {
- cmd = new(Config)
- cmd.network = network
- return
-}
-
-func (cmd *Config) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "config",
- Description: "Show the config for an application or entity",
- Usage: "BROOKLYN_NAME SCOPE config",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Config) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- if c.Args().Present() {
- configValue, err := entity_config.ConfigValue(cmd.network, scope.Application, scope.Entity, c.Args().First())
-
- if nil != err {
- error_handler.ErrorExit(err)
- }
- displayValue, err := stringRepresentation(configValue)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(displayValue)
-
- } else {
- config, err := entity_config.ConfigCurrentState(cmd.network, scope.Application, scope.Entity)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Key", "Value"})
- for key, value := range config {
- table.Add(key, fmt.Sprintf("%v", value))
- }
- table.Print()
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/delete-catalog-application.go
----------------------------------------------------------------------
diff --git a/commands/delete-catalog-application.go b/commands/delete-catalog-application.go
deleted file mode 100644
index f289bbd..0000000
--- a/commands/delete-catalog-application.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type DeleteCatalogApplication struct {
- network *net.Network
-}
-
-func NewDeleteCatalogApplication(network *net.Network) (cmd *DeleteCatalogApplication) {
- cmd = new(DeleteCatalogApplication)
- cmd.network = network
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/delete-catalog-entity.go
----------------------------------------------------------------------
diff --git a/commands/delete-catalog-entity.go b/commands/delete-catalog-entity.go
deleted file mode 100644
index 5953fff..0000000
--- a/commands/delete-catalog-entity.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type DeleteCatalogEntity struct {
- network *net.Network
-}
-
-func NewDeleteCatalogEntity(network *net.Network) (cmd *DeleteCatalogEntity) {
- cmd = new(DeleteCatalogEntity)
- cmd.network = network
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/delete-catalog-policy.go
----------------------------------------------------------------------
diff --git a/commands/delete-catalog-policy.go b/commands/delete-catalog-policy.go
deleted file mode 100644
index c6b29a6..0000000
--- a/commands/delete-catalog-policy.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type DeleteCatalogPolicy struct {
- network *net.Network
-}
-
-func NewDeleteCatalogPolicy(network *net.Network) (cmd *DeleteCatalogPolicy) {
- cmd = new(DeleteCatalogPolicy)
- cmd.network = network
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/delete.go
----------------------------------------------------------------------
diff --git a/commands/delete.go b/commands/delete.go
deleted file mode 100644
index 90c60f9..0000000
--- a/commands/delete.go
+++ /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.
- */
-package commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/application"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type Delete struct {
- network *net.Network
-}
-
-func NewDelete(network *net.Network) (cmd *Delete) {
- cmd = new(Delete)
- cmd.network = network
- return
-}
-
-func (cmd *Delete) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "delete",
- Description: "* Delete (expunge) a brooklyn application",
- Usage: "BROOKLYN_NAME SCOPE delete",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Delete) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- del, err := application.Delete(cmd.network, scope.Application)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(del)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/deploy.go
----------------------------------------------------------------------
diff --git a/commands/deploy.go b/commands/deploy.go
deleted file mode 100644
index bc42b08..0000000
--- a/commands/deploy.go
+++ /dev/null
@@ -1,85 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/api/application"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/models"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/apache/brooklyn-client/terminal"
- "github.com/urfave/cli"
- "io/ioutil"
- "os"
- "strings"
-)
-
-type Deploy struct {
- network *net.Network
-}
-
-func NewDeploy(network *net.Network) (cmd *Deploy) {
- cmd = new(Deploy)
- cmd.network = network
- return
-}
-
-func (cmd *Deploy) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "deploy",
- Description: "Deploy a new application from the given YAML (read from file or URL, or stdin)",
- Usage: "BROOKLYN_NAME deploy ( FILE | URL | '-' )",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Deploy) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
-
- var create models.TaskSummary
- var err error
- var blueprint []byte
- if c.Args().First() == "" {
- error_handler.ErrorExit("A filename or URL or '-' must be provided as the first argument", error_handler.CLIUsageErrorExitCode)
- }
- if c.Args().First() == "-" {
- blueprint, err = ioutil.ReadAll(os.Stdin)
- if err != nil {
- error_handler.ErrorExit(err)
- }
- create, err = application.CreateFromBytes(cmd.network, blueprint)
- } else {
- create, err = application.Create(cmd.network, c.Args().First())
- }
- if nil != err {
- if httpErr, ok := err.(net.HttpError); ok {
- error_handler.ErrorExit(strings.Join([]string{httpErr.Status, httpErr.Body}, "\n"), httpErr.Code)
- } else {
- error_handler.ErrorExit(err)
- }
- }
- table := terminal.NewTable([]string{"Id:", create.EntityId})
- table.Add("Name:", create.EntityDisplayName)
- table.Add("Status:", create.CurrentStatus)
- table.Print()
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/destroy-policy.go
----------------------------------------------------------------------
diff --git a/commands/destroy-policy.go b/commands/destroy-policy.go
deleted file mode 100644
index 4ea37ec..0000000
--- a/commands/destroy-policy.go
+++ /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.
- */
-package commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/entity_policies"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type DestroyPolicy struct {
- network *net.Network
-}
-
-func NewDestroyPolicy(network *net.Network) (cmd *DestroyPolicy) {
- cmd = new(DestroyPolicy)
- cmd.network = network
- return
-}
-
-func (cmd *DestroyPolicy) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "destroy-policy",
- Description: "Destroy a policy",
- Usage: "BROOKLYN_NAME SCOPE destroy-policy POLICY",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *DestroyPolicy) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- spec, err := entity_policies.DestroyPolicy(cmd.network, scope.Application, scope.Entity, c.Args().First())
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(spec)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/effector.go
----------------------------------------------------------------------
diff --git a/commands/effector.go b/commands/effector.go
deleted file mode 100644
index aeff664..0000000
--- a/commands/effector.go
+++ /dev/null
@@ -1,70 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/api/entity_effectors"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/apache/brooklyn-client/terminal"
- "github.com/urfave/cli"
- "strings"
-)
-
-type Effector struct {
- network *net.Network
-}
-
-func NewEffector(network *net.Network) (cmd *Effector) {
- cmd = new(Effector)
- cmd.network = network
- return
-}
-
-func (cmd *Effector) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "effector",
- Description: "Show the effectors for an application or entity",
- Usage: "BROOKLYN_NAME SCOPE effector [ NAME ]",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Effector) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- effectors, err := entity_effectors.EffectorList(cmd.network, scope.Application, scope.Entity)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Name", "Description", "Parameters"})
- for _, effector := range effectors {
- var parameters []string
- for _, parameter := range effector.Parameters {
- parameters = append(parameters, parameter.Name)
- }
- if !c.Args().Present() || c.Args().First() == effector.Name {
- table.Add(effector.Name, effector.Description, strings.Join(parameters, ","))
- }
- }
- table.Print()
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/entity.go
----------------------------------------------------------------------
diff --git a/commands/entity.go b/commands/entity.go
deleted file mode 100644
index e5903c9..0000000
--- a/commands/entity.go
+++ /dev/null
@@ -1,127 +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 commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/entities"
- "github.com/apache/brooklyn-client/api/entity_sensors"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/apache/brooklyn-client/terminal"
- "github.com/urfave/cli"
- "os"
-)
-
-type Entity struct {
- network *net.Network
-}
-
-func NewEntity(network *net.Network) (cmd *Entity) {
- cmd = new(Entity)
- cmd.network = network
- return
-}
-
-func (cmd *Entity) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "entity",
- Aliases: []string{"entities", "ent", "ents"},
- Description: "Show the entities of an application or entity",
- Usage: "BROOKLYN_NAME SCOPE entity [ENTITYID]",
- Flags: []cli.Flag{
- cli.StringSliceFlag{
- Name: "children, c",
- Usage: "List children of the entity",
- },
- },
- }
-}
-
-func (cmd *Entity) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- if c.NumFlags() > 0 && c.FlagNames()[0] == "children" {
- cmd.listentity(scope.Application, c.StringSlice("children")[0])
- } else {
- if c.Args().Present() {
- cmd.show(scope.Application, c.Args().First())
- } else {
- if scope.Entity == scope.Application {
- cmd.listapp(scope.Application)
- } else {
- cmd.listentity(scope.Application, scope.Entity)
- }
- }
- }
-}
-
-const serviceStateSensor = "service.state"
-const serviceIsUp = "service.isUp"
-
-func (cmd *Entity) show(application, entity string) {
- summary, err := entities.GetEntity(cmd.network, application, entity)
- if nil != err {
- fmt.Fprintf(os.Stderr, "Error: %s\n", err)
- os.Exit(1)
- }
- table := terminal.NewTable([]string{"Id:", summary.Id})
- table.Add("Name:", summary.Name)
- configState, err := entity_sensors.CurrentState(cmd.network, application, entity)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- if serviceState, ok := configState[serviceStateSensor]; ok {
- table.Add("Status:", fmt.Sprintf("%v", serviceState))
- }
- if serviceIsUp, ok := configState[serviceIsUp]; ok {
- table.Add("ServiceUp:", fmt.Sprintf("%v", serviceIsUp))
- }
- table.Add("Type:", summary.Type)
- table.Add("CatalogItemId:", summary.CatalogItemId)
- table.Print()
-}
-
-func (cmd *Entity) listapp(application string) {
- entitiesList, err := entities.EntityList(cmd.network, application)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Id", "Name", "Type"})
- for _, entityitem := range entitiesList {
- table.Add(entityitem.Id, entityitem.Name, entityitem.Type)
- }
- table.Print()
-}
-
-func (cmd *Entity) listentity(application string, entity string) {
- entitiesList, err := entities.Children(cmd.network, application, entity)
- if nil != err {
- error_handler.ErrorExit(err)
- }
-
- table := terminal.NewTable([]string{"Id", "Name", "Type"})
- for _, entityitem := range entitiesList {
- table.Add(entityitem.Id, entityitem.Name, entityitem.Type)
- }
- table.Print()
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/invoke.go
----------------------------------------------------------------------
diff --git a/commands/invoke.go b/commands/invoke.go
deleted file mode 100644
index a719ed7..0000000
--- a/commands/invoke.go
+++ /dev/null
@@ -1,203 +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 commands
-
-import (
- "errors"
- "fmt"
- "github.com/apache/brooklyn-client/api/entity_effectors"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
- "io/ioutil"
- "strings"
-)
-
-type Invoke struct {
- network *net.Network
-}
-
-type Stop struct {
- Invoke
-}
-
-type Start struct {
- Invoke
-}
-
-type Restart struct {
- Invoke
-}
-
-func NewInvoke(network *net.Network) (cmd *Invoke) {
- cmd = new(Invoke)
- cmd.network = network
- return
-}
-
-func NewInvokeStop(network *net.Network) (cmd *Stop) {
- cmd = new(Stop)
- cmd.network = network
- return
-}
-
-func NewInvokeStart(network *net.Network) (cmd *Start) {
- cmd = new(Start)
- cmd.network = network
- return
-}
-
-func NewInvokeRestart(network *net.Network) (cmd *Restart) {
- cmd = new(Restart)
- cmd.network = network
- return
-}
-
-var paramFlags = []cli.Flag{
- cli.StringSliceFlag{
- Name: "param, P",
- Usage: "Parameter and value separated by '=', e.g. -P x=y. If the parameter value is complex or multi-" +
- "lined it may be provided in a file and referenced as: '@<file>', e.g. -P x=@/path/to/file.",
- },
-}
-
-func (cmd *Invoke) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "invoke",
- Description: "Invoke an effector of an application and entity",
- Usage: "BROOKLYN_NAME EFF-SCOPE invoke [ parameter-options ]",
- Flags: paramFlags,
- }
-}
-
-func (cmd *Stop) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "stop",
- Description: "Invoke stop effector on an application and entity",
- Usage: "BROOKLYN_NAME ENT-SCOPE stop [ parameter-options ]",
- Flags: paramFlags,
- }
-}
-
-func (cmd *Start) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "start",
- Description: "Invoke start effector on an application and entity",
- Usage: "BROOKLYN_NAME ENT-SCOPE start [ parameter-options ]",
- Flags: paramFlags,
- }
-}
-
-func (cmd *Restart) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "restart",
- Description: "Invoke restart effector on an application and entity",
- Usage: "BROOKLYN_NAME ENT-SCOPE restart [ parameter-options ]",
- Flags: paramFlags,
- }
-}
-
-func (cmd *Invoke) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- parms := c.StringSlice("param")
- invoke(cmd.network, scope.Application, scope.Entity, scope.Effector, parms)
-}
-
-const stopEffector = "stop"
-
-func (cmd *Stop) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- parms := c.StringSlice("param")
- invoke(cmd.network, scope.Application, scope.Entity, stopEffector, parms)
-}
-
-const startEffector = "start"
-
-func (cmd *Start) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- parms := c.StringSlice("param")
- invoke(cmd.network, scope.Application, scope.Entity, startEffector, parms)
-}
-
-const restartEffector = "restart"
-
-func (cmd *Restart) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- parms := c.StringSlice("param")
- invoke(cmd.network, scope.Application, scope.Entity, restartEffector, parms)
-}
-
-func invoke(network *net.Network, application, entity, effector string, parms []string) {
- names, vals, err := extractParams(parms)
- result, err := entity_effectors.TriggerEffector(network, application, entity, effector, names, vals)
- if nil != err {
- error_handler.ErrorExit(err)
- } else {
- if "" != result {
- fmt.Println(result)
- }
- }
-}
-
-func extractParams(parms []string) ([]string, []string, error) {
- names := make([]string, len(parms))
- vals := make([]string, len(parms))
- var err error
- for i, parm := range parms {
- index := strings.Index(parm, "=")
- if index < 0 {
- return names, vals, errors.New("Parameter value not provided: " + parm)
- }
- names[i] = parm[0:index]
- vals[i], err = extractParamValue(parm[index+1:])
- }
- return names, vals, err
-}
-
-const paramDataPrefix string = "@"
-
-func extractParamValue(rawParam string) (string, error) {
- var err error
- var val string
- if strings.HasPrefix(rawParam, paramDataPrefix) {
- // strip the data prefix from the filename before reading
- val, err = readParamFromFile(rawParam[len(paramDataPrefix):])
- } else {
- val = rawParam
- err = nil
- }
- return val, err
-}
-
-// returning a string rather than byte array, assuming non-binary
-// TODO - if necessary support binary data sending to effector
-func readParamFromFile(filename string) (string, error) {
- dat, err := ioutil.ReadFile(filename)
- return string(dat), err
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/list.go
----------------------------------------------------------------------
diff --git a/commands/list.go b/commands/list.go
deleted file mode 100644
index 7758568..0000000
--- a/commands/list.go
+++ /dev/null
@@ -1,90 +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 commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/command"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
- "strings"
-)
-
-type List struct {
- network *net.Network
- listCommands map[string]command.Command
-}
-
-func NewList(network *net.Network) (cmd *List) {
- cmd = new(List)
- cmd.network = network
- cmd.listCommands = map[string]command.Command{
- // ListApplicationCommand: NewApplications(cmd.network),
- // ListEntityCommand: NewEntities(cmd.network),
- // ListSensorCommand: NewSensors(cmd.network),
- // ListEffectorCommand: NewEffector(cmd.network),
- }
- return
-}
-
-const ListApplicationCommand = "application"
-const ListEntityCommand = "entities"
-const ListSensorCommand = "sensors"
-const ListEffectorCommand = "effectors"
-
-var listCommands = []string{
- ListApplicationCommand,
- ListEntityCommand,
- ListSensorCommand,
- ListEffectorCommand,
-}
-var listCommandsUsage = strings.Join(listCommands, " | ")
-
-func (cmd *List) SubCommandNames() []string {
- return listCommands
-}
-
-func (cmd *List) SubCommand(name string) command.Command {
- return cmd.listCommands[name]
-}
-
-func (cmd *List) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "list",
- Description: "List details for a variety of operands",
- Usage: "BROOKLYN_NAME SCOPE list (" + listCommandsUsage + ")",
- Flags: []cli.Flag{},
- Operands: []command_metadata.CommandMetadata{
- cmd.SubCommand(ListApplicationCommand).Metadata(),
- cmd.SubCommand(ListEntityCommand).Metadata(),
- cmd.SubCommand(ListSensorCommand).Metadata(),
- cmd.SubCommand(ListEffectorCommand).Metadata(),
- },
- }
-}
-
-func (cmd *List) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- fmt.Printf("Unrecognised item for list, please use one of (%s)\n", listCommandsUsage)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/locations.go
----------------------------------------------------------------------
diff --git a/commands/locations.go b/commands/locations.go
deleted file mode 100644
index f197130..0000000
--- a/commands/locations.go
+++ /dev/null
@@ -1,63 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/api/locations"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/apache/brooklyn-client/terminal"
- "github.com/urfave/cli"
-)
-
-type Locations struct {
- network *net.Network
-}
-
-func NewLocations(network *net.Network) (cmd *Locations) {
- cmd = new(Locations)
- cmd.network = network
- return
-}
-
-func (cmd *Locations) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "locations",
- Description: "* List the available locations",
- Usage: "BROOKLYN_NAME locations",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Locations) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- locationList, err := locations.LocationList(cmd.network)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Id", "Name", "Spec"})
- for _, location := range locationList {
- table.Add(location.Id, location.Name, location.Spec)
- }
- table.Print()
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/login.go
----------------------------------------------------------------------
diff --git a/commands/login.go b/commands/login.go
deleted file mode 100644
index df63b33..0000000
--- a/commands/login.go
+++ /dev/null
@@ -1,113 +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 commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/version"
- "github.com/apache/brooklyn-client/command_metadata"
- "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"
- "github.com/urfave/cli"
- "golang.org/x/crypto/ssh/terminal"
- "syscall"
-)
-
-type Login struct {
- network *net.Network
- config *io.Config
-}
-
-func NewLogin(network *net.Network, config *io.Config) (cmd *Login) {
- cmd = new(Login)
- cmd.network = network
- cmd.config = config
- return
-}
-
-func (cmd *Login) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "login",
- Description: "Login to brooklyn",
- Usage: "BROOKLYN_NAME login URL [USER [PASSWORD]]",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Login) Run(scope scope.Scope, c *cli.Context) {
- if !c.Args().Present() {
- error_handler.ErrorExit("A URL must be provided as the first argument", error_handler.CLIUsageErrorExitCode)
- }
-
- // If an argument was not supplied, it is set to empty string
- cmd.network.BrooklynUrl = c.Args().Get(0)
- cmd.network.BrooklynUser = c.Args().Get(1)
- cmd.network.BrooklynPass = c.Args().Get(2)
- cmd.network.SkipSslChecks = c.GlobalBool("skipSslChecks")
-
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
-
- // Strip off trailing '/' from URL if present.
- if cmd.network.BrooklynUrl[len(cmd.network.BrooklynUrl)-1] == '/' {
- if len(cmd.network.BrooklynUrl) == 1 {
- error_handler.ErrorExit("URL must not be a single \"/\" character", error_handler.CLIUsageErrorExitCode)
- }
- cmd.network.BrooklynUrl = cmd.network.BrooklynUrl[0 : len(cmd.network.BrooklynUrl)-1]
- }
-
- // Prompt for password if not supplied (password is not echoed to screen
- if cmd.network.BrooklynUser != "" && cmd.network.BrooklynPass == "" {
- fmt.Print("Enter Password: ")
- bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
- if err != nil {
- error_handler.ErrorExit(err)
- }
- fmt.Printf("\n")
- cmd.network.BrooklynPass = string(bytePassword)
- }
-
- if cmd.config.Map == nil {
- cmd.config.Map = make(map[string]interface{})
- }
- // now persist these credentials to the yaml file
- auth, ok := cmd.config.Map["auth"].(map[string]interface{})
- if !ok {
- auth = make(map[string]interface{})
- cmd.config.Map["auth"] = auth
- }
-
- auth[cmd.network.BrooklynUrl] = map[string]string{
- "username": cmd.network.BrooklynUser,
- "password": cmd.network.BrooklynPass,
- }
-
- cmd.config.Map["target"] = cmd.network.BrooklynUrl
- cmd.config.Map["skipSslChecks"] = cmd.network.SkipSslChecks
- cmd.config.Write()
-
- loginVersion, err := version.Version(cmd.network)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Printf("Connected to Brooklyn version %s at %s\n", loginVersion.Version, cmd.network.BrooklynUrl)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/policy.go
----------------------------------------------------------------------
diff --git a/commands/policy.go b/commands/policy.go
deleted file mode 100644
index 1d587fd..0000000
--- a/commands/policy.go
+++ /dev/null
@@ -1,114 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/api/entity_policies"
- "github.com/apache/brooklyn-client/api/entity_policy_config"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/models"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/apache/brooklyn-client/terminal"
- "github.com/urfave/cli"
- "sort"
-)
-
-type Policy struct {
- network *net.Network
-}
-
-type policyConfigList []models.PolicyConfigList
-
-// Len is the number of elements in the collection.
-func (configs policyConfigList) Len() int {
- return len(configs)
-}
-
-// Less reports whether the element with
-// index i should sort before the element with index j.
-func (configs policyConfigList) Less(i, j int) bool {
- return configs[i].Name < configs[j].Name
-}
-
-// Swap swaps the elements with indexes i and j.
-func (configs policyConfigList) Swap(i, j int) {
- temp := configs[i]
- configs[i] = configs[j]
- configs[j] = temp
-}
-
-func NewPolicy(network *net.Network) (cmd *Policy) {
- cmd = new(Policy)
- cmd.network = network
- return
-}
-
-func (cmd *Policy) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "policy",
- Aliases: []string{"policies", "pol", "pols"},
- Description: "Show the policies for an application or entity",
- Usage: "BROOKLYN_NAME SCOPE policy [NAME]",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Policy) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- if c.Args().Present() {
- cmd.show(scope.Application, scope.Entity, c.Args().First())
- } else {
- cmd.list(scope.Application, scope.Entity)
- }
-}
-
-func (cmd *Policy) show(application, entity, policy string) {
- configs, err := entity_policy_config.GetAllConfigValues(cmd.network, application, entity, policy)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Name", "Value", "Description"})
- var theConfigs policyConfigList = configs
- sort.Sort(theConfigs)
-
- for _, config := range theConfigs {
- value, err := entity_policy_config.GetConfigValue(cmd.network, application, entity, policy, config.Name)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table.Add(config.Name, value, config.Description)
- }
- table.Print()
-}
-
-func (cmd *Policy) list(application, entity string) {
- policies, err := entity_policies.PolicyList(cmd.network, application, entity)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table := terminal.NewTable([]string{"Id", "Name", "State"})
- for _, policy := range policies {
- table.Add(policy.Id, policy.Name, string(policy.State))
- }
- table.Print()
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/rename.go
----------------------------------------------------------------------
diff --git a/commands/rename.go b/commands/rename.go
deleted file mode 100644
index 7891971..0000000
--- a/commands/rename.go
+++ /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.
- */
-package commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/entities"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type Rename struct {
- network *net.Network
-}
-
-func NewRename(network *net.Network) (cmd *Rename) {
- cmd = new(Rename)
- cmd.network = network
- return
-}
-
-func (cmd *Rename) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "rename",
- Description: "Rename an application or entity",
- Usage: "BROOKLYN_NAME SCOPE rename NEW_NAME",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Rename) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- rename, err := entities.Rename(cmd.network, scope.Application, scope.Entity, c.Args().First())
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(rename)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/reset-catalog.go
----------------------------------------------------------------------
diff --git a/commands/reset-catalog.go b/commands/reset-catalog.go
deleted file mode 100644
index 6830399..0000000
--- a/commands/reset-catalog.go
+++ /dev/null
@@ -1,33 +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 commands
-
-import (
- "github.com/apache/brooklyn-client/net"
-)
-
-type ResetCatalog struct {
- network *net.Network
-}
-
-func NewResetCatalog(network *net.Network) (cmd *ResetCatalog) {
- cmd = new(ResetCatalog)
- cmd.network = network
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/sensor.go
----------------------------------------------------------------------
diff --git a/commands/sensor.go b/commands/sensor.go
deleted file mode 100644
index ac75660..0000000
--- a/commands/sensor.go
+++ /dev/null
@@ -1,118 +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 commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/entity_sensors"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/models"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/apache/brooklyn-client/terminal"
- "github.com/urfave/cli"
- "sort"
-)
-
-type Sensor struct {
- network *net.Network
-}
-
-type sensorList []models.SensorSummary
-
-// Len is the number of elements in the collection.
-func (sensors sensorList) Len() int {
- return len(sensors)
-}
-
-// Less reports whether the element with
-// index i should sort before the element with index j.
-func (sensors sensorList) Less(i, j int) bool {
- return sensors[i].Name < sensors[j].Name
-}
-
-// Swap swaps the elements with indexes i and j.
-func (sensors sensorList) Swap(i, j int) {
- temp := sensors[i]
- sensors[i] = sensors[j]
- sensors[j] = temp
-}
-
-func NewSensor(network *net.Network) (cmd *Sensor) {
- cmd = new(Sensor)
- cmd.network = network
- return
-}
-
-func (cmd *Sensor) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "sensor",
- Description: "Show values of all sensors or named sensor for an application or entity",
- Usage: "BROOKLYN_NAME SCOPE sensor [ SENSOR_NAME ]",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Sensor) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- if c.Args().Present() {
- cmd.show(scope.Application, scope.Entity, c.Args().First())
- } else {
- cmd.list(scope.Application, scope.Entity)
- }
-}
-
-func (cmd *Sensor) show(application, entity, sensor string) {
- sensorValue, err := entity_sensors.SensorValue(cmd.network, application, entity, sensor)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- displayValue, err := stringRepresentation(sensorValue)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(displayValue)
-}
-
-func (cmd *Sensor) list(application, entity string) {
- sensors, err := entity_sensors.SensorList(cmd.network, application, entity)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- var theSensors sensorList = sensors
- table := terminal.NewTable([]string{"Name", "Description", "Value"})
-
- sort.Sort(theSensors)
-
- for _, sensor := range theSensors {
- value, err := entity_sensors.SensorValue(cmd.network, application, entity, sensor.Name)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- displayValue, err := stringRepresentation(value)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- table.Add(sensor.Name, sensor.Description, displayValue)
- }
- table.Print()
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/set.go
----------------------------------------------------------------------
diff --git a/commands/set.go b/commands/set.go
deleted file mode 100644
index ae1a594..0000000
--- a/commands/set.go
+++ /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.
- */
-package commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/entity_config"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type SetConfig struct {
- network *net.Network
-}
-
-func NewSetConfig(network *net.Network) (cmd *SetConfig) {
- cmd = new(SetConfig)
- cmd.network = network
- return
-}
-
-func (cmd *SetConfig) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "set",
- Description: "Set config for an entity",
- Usage: "BROOKLYN_NAME CONFIG-SCOPE set VALUE",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *SetConfig) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- response, err := entity_config.SetConfig(cmd.network, scope.Application, scope.Entity, scope.Config, c.Args().First())
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(response)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/spec.go
----------------------------------------------------------------------
diff --git a/commands/spec.go b/commands/spec.go
deleted file mode 100644
index 06819b9..0000000
--- a/commands/spec.go
+++ /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.
- */
-package commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/entities"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type Spec struct {
- network *net.Network
-}
-
-func NewSpec(network *net.Network) (cmd *Spec) {
- cmd = new(Spec)
- cmd.network = network
- return
-}
-
-func (cmd *Spec) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "spec",
- Description: "Get the YAML spec used to create the entity, if available",
- Usage: "BROOKLYN_NAME SCOPE spec",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Spec) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- spec, err := entities.Spec(cmd.network, scope.Application, scope.Entity)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(spec)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/start-policy.go
----------------------------------------------------------------------
diff --git a/commands/start-policy.go b/commands/start-policy.go
deleted file mode 100644
index 68dbec7..0000000
--- a/commands/start-policy.go
+++ /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.
- */
-package commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/entity_policies"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type StartPolicy struct {
- network *net.Network
-}
-
-func NewStartPolicy(network *net.Network) (cmd *StartPolicy) {
- cmd = new(StartPolicy)
- cmd.network = network
- return
-}
-
-func (cmd *StartPolicy) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "start-policy",
- Description: "Start or resume a policy",
- Usage: "BROOKLYN_NAME SCOPE start-policy POLICY",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *StartPolicy) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- spec, err := entity_policies.StartPolicy(cmd.network, scope.Application, scope.Entity, c.Args().First())
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(spec)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/stop-policy.go
----------------------------------------------------------------------
diff --git a/commands/stop-policy.go b/commands/stop-policy.go
deleted file mode 100644
index 2700802..0000000
--- a/commands/stop-policy.go
+++ /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.
- */
-package commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/entity_policies"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type StopPolicy struct {
- network *net.Network
-}
-
-func NewStopPolicy(network *net.Network) (cmd *StopPolicy) {
- cmd = new(StopPolicy)
- cmd.network = network
- return
-}
-
-func (cmd *StopPolicy) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "stop-policy",
- Description: "Suspends a policy",
- Usage: "BROOKLYN_NAME SCOPE stop-policy POLICY",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *StopPolicy) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- spec, err := entity_policies.StopPolicy(cmd.network, scope.Application, scope.Entity, c.Args().First())
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(spec)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/tree.go
----------------------------------------------------------------------
diff --git a/commands/tree.go b/commands/tree.go
deleted file mode 100644
index 5665997..0000000
--- a/commands/tree.go
+++ /dev/null
@@ -1,78 +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 commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/application"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/models"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type Tree struct {
- network *net.Network
-}
-
-func NewTree(network *net.Network) (cmd *Tree) {
- cmd = new(Tree)
- cmd.network = network
- return
-}
-
-func (cmd *Tree) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "tree",
- Description: "* Show the tree of all applications",
- Usage: "BROOKLYN_NAME tree",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Tree) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- trees, err := application.Tree(cmd.network)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- cmd.printTrees(trees, "")
-}
-
-func (cmd *Tree) printTrees(trees []models.Tree, indent string) {
- for i, app := range trees {
- cmd.printTree(app, indent, i == len(trees)-1)
- }
-}
-
-func (cmd *Tree) printTree(tree models.Tree, indent string, last bool) {
- fmt.Println(indent+"|-", tree.Name)
- fmt.Println(indent+"+-", tree.Type)
-
- if last {
- indent = indent + " "
- } else {
- indent = indent + "| "
- }
- cmd.printTrees(tree.Children, indent)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/utils.go
----------------------------------------------------------------------
diff --git a/commands/utils.go b/commands/utils.go
deleted file mode 100644
index a4533b1..0000000
--- a/commands/utils.go
+++ /dev/null
@@ -1,38 +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 commands
-
-import (
- "encoding/json"
-)
-
-func stringRepresentation(value interface{}) (string, error) {
- var result string
- switch value.(type) {
- case string:
- result = value.(string) // use string value as-is
- default:
- json, err := json.Marshal(value)
- if err != nil {
- return "", err
- }
- result = string(json) // return JSON text representation of value object
- }
- return result, nil
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/commands/version.go
----------------------------------------------------------------------
diff --git a/commands/version.go b/commands/version.go
deleted file mode 100644
index 39de4b6..0000000
--- a/commands/version.go
+++ /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.
- */
-package commands
-
-import (
- "fmt"
- "github.com/apache/brooklyn-client/api/version"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/error_handler"
- "github.com/apache/brooklyn-client/net"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type Version struct {
- network *net.Network
-}
-
-func NewVersion(network *net.Network) (cmd *Version) {
- cmd = new(Version)
- cmd.network = network
- return
-}
-
-func (cmd *Version) Metadata() command_metadata.CommandMetadata {
- return command_metadata.CommandMetadata{
- Name: "version",
- Description: "Display the version of the connected Brooklyn",
- Usage: "BROOKLYN_NAME version",
- Flags: []cli.Flag{},
- }
-}
-
-func (cmd *Version) Run(scope scope.Scope, c *cli.Context) {
- if err := net.VerifyLoginURL(cmd.network); err != nil {
- error_handler.ErrorExit(err)
- }
- version, err := version.Version(cmd.network)
- if nil != err {
- error_handler.ErrorExit(err)
- }
- fmt.Println(version.Version)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/error_handler/error.go
----------------------------------------------------------------------
diff --git a/error_handler/error.go b/error_handler/error.go
deleted file mode 100644
index 8238c2b..0000000
--- a/error_handler/error.go
+++ /dev/null
@@ -1,46 +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 error_handler
-
-import (
- "fmt"
- "os"
-)
-
-const CLIUsageErrorExitCode int = 1
-const CliGenericErrorExitCode int = 2
-const CLITrapErrorCode int = 3
-
-func ErrorExit(errorvalue interface{}, errorcode ...int) {
- switch errorvalue.(type) {
- case error:
- fmt.Fprintln(os.Stderr, errorvalue)
- case string:
- fmt.Fprintln(os.Stderr, errorvalue)
- case nil:
- fmt.Fprintln(os.Stderr, "No error message provided")
- default:
- fmt.Fprintln(os.Stderr, "Unknown Error Type: ", errorvalue)
- }
- if len(errorcode) > 0 {
- os.Exit(errorcode[0])
- } else {
- os.Exit(CliGenericErrorExitCode)
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/glide.lock
----------------------------------------------------------------------
diff --git a/glide.lock b/glide.lock
deleted file mode 100644
index f214d4c..0000000
--- a/glide.lock
+++ /dev/null
@@ -1,10 +0,0 @@
-hash: 1d87d5643857ae47cd40cc29e7b9b813198980c84b3491376b3561c467e37994
-updated: 2016-06-02T21:50:02.953614402+01:00
-imports:
-- name: github.com/urfave/cli
- version: 5db74198dee1cfe60cf06a611d03a420361baad6
-- name: golang.org/x/crypto
- version: 1f22c0103821b9390939b6776727195525381532
- subpackages:
- - ssh/terminal
-devImports: []
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/glide.yaml
----------------------------------------------------------------------
diff --git a/glide.yaml b/glide.yaml
deleted file mode 100644
index e2cf5c9..0000000
--- a/glide.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-package: github.com/apache/brooklyn-client
-import:
-- package: github.com/urfave/cli
-- package: golang.org/x/crypto
- subpackages:
- - ssh/terminal
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/io/config.go
----------------------------------------------------------------------
diff --git a/io/config.go b/io/config.go
deleted file mode 100644
index ea9ca01..0000000
--- a/io/config.go
+++ /dev/null
@@ -1,72 +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 io
-
-import (
- "encoding/json"
- "os"
- "path/filepath"
-
- "github.com/apache/brooklyn-client/error_handler"
-)
-
-type Config struct {
- FilePath string
- Map map[string]interface{}
-}
-
-func GetConfig() (config *Config) {
- // check to see if $BRCLI_HOME/.brooklyn_cli or $HOME/.brooklyn_cli exists
- // Then parse it to get user credentials
- config = new(Config)
- if os.Getenv("BRCLI_HOME") != "" {
- config.FilePath = filepath.Join(os.Getenv("BRCLI_HOME"), ".brooklyn_cli")
- } else {
- config.FilePath = filepath.Join(os.Getenv("HOME"), ".brooklyn_cli")
- }
- if _, err := os.Stat(config.FilePath); os.IsNotExist(err) {
- config.Map = make(map[string]interface{})
- config.Write()
- }
- config.Read()
- return
-}
-
-func (config *Config) Write() {
- // Create file as read/write by user (but does not change perms of existing file)
- fileToWrite, err := os.OpenFile(config.FilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
- if err != nil {
- error_handler.ErrorExit(err)
- }
- defer fileToWrite.Close()
-
- enc := json.NewEncoder(fileToWrite)
- enc.Encode(config.Map)
-}
-
-func (config *Config) Read() {
- fileToRead, err := os.Open(config.FilePath)
- if err != nil {
- error_handler.ErrorExit(err)
- }
- defer fileToRead.Close()
-
- dec := json.NewDecoder(fileToRead)
- dec.Decode(&config.Map)
-}
[06/10] brooklyn-client git commit: move rest-client to
brooklyn-client
Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/entity.go
----------------------------------------------------------------------
diff --git a/cli/commands/entity.go b/cli/commands/entity.go
new file mode 100644
index 0000000..e5903c9
--- /dev/null
+++ b/cli/commands/entity.go
@@ -0,0 +1,127 @@
+/*
+ * 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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entities"
+ "github.com/apache/brooklyn-client/api/entity_sensors"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/urfave/cli"
+ "os"
+)
+
+type Entity struct {
+ network *net.Network
+}
+
+func NewEntity(network *net.Network) (cmd *Entity) {
+ cmd = new(Entity)
+ cmd.network = network
+ return
+}
+
+func (cmd *Entity) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "entity",
+ Aliases: []string{"entities", "ent", "ents"},
+ Description: "Show the entities of an application or entity",
+ Usage: "BROOKLYN_NAME SCOPE entity [ENTITYID]",
+ Flags: []cli.Flag{
+ cli.StringSliceFlag{
+ Name: "children, c",
+ Usage: "List children of the entity",
+ },
+ },
+ }
+}
+
+func (cmd *Entity) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ if c.NumFlags() > 0 && c.FlagNames()[0] == "children" {
+ cmd.listentity(scope.Application, c.StringSlice("children")[0])
+ } else {
+ if c.Args().Present() {
+ cmd.show(scope.Application, c.Args().First())
+ } else {
+ if scope.Entity == scope.Application {
+ cmd.listapp(scope.Application)
+ } else {
+ cmd.listentity(scope.Application, scope.Entity)
+ }
+ }
+ }
+}
+
+const serviceStateSensor = "service.state"
+const serviceIsUp = "service.isUp"
+
+func (cmd *Entity) show(application, entity string) {
+ summary, err := entities.GetEntity(cmd.network, application, entity)
+ if nil != err {
+ fmt.Fprintf(os.Stderr, "Error: %s\n", err)
+ os.Exit(1)
+ }
+ table := terminal.NewTable([]string{"Id:", summary.Id})
+ table.Add("Name:", summary.Name)
+ configState, err := entity_sensors.CurrentState(cmd.network, application, entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ if serviceState, ok := configState[serviceStateSensor]; ok {
+ table.Add("Status:", fmt.Sprintf("%v", serviceState))
+ }
+ if serviceIsUp, ok := configState[serviceIsUp]; ok {
+ table.Add("ServiceUp:", fmt.Sprintf("%v", serviceIsUp))
+ }
+ table.Add("Type:", summary.Type)
+ table.Add("CatalogItemId:", summary.CatalogItemId)
+ table.Print()
+}
+
+func (cmd *Entity) listapp(application string) {
+ entitiesList, err := entities.EntityList(cmd.network, application)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Name", "Type"})
+ for _, entityitem := range entitiesList {
+ table.Add(entityitem.Id, entityitem.Name, entityitem.Type)
+ }
+ table.Print()
+}
+
+func (cmd *Entity) listentity(application string, entity string) {
+ entitiesList, err := entities.Children(cmd.network, application, entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+
+ table := terminal.NewTable([]string{"Id", "Name", "Type"})
+ for _, entityitem := range entitiesList {
+ table.Add(entityitem.Id, entityitem.Name, entityitem.Type)
+ }
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/invoke.go
----------------------------------------------------------------------
diff --git a/cli/commands/invoke.go b/cli/commands/invoke.go
new file mode 100644
index 0000000..a719ed7
--- /dev/null
+++ b/cli/commands/invoke.go
@@ -0,0 +1,203 @@
+/*
+ * 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 commands
+
+import (
+ "errors"
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entity_effectors"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+ "io/ioutil"
+ "strings"
+)
+
+type Invoke struct {
+ network *net.Network
+}
+
+type Stop struct {
+ Invoke
+}
+
+type Start struct {
+ Invoke
+}
+
+type Restart struct {
+ Invoke
+}
+
+func NewInvoke(network *net.Network) (cmd *Invoke) {
+ cmd = new(Invoke)
+ cmd.network = network
+ return
+}
+
+func NewInvokeStop(network *net.Network) (cmd *Stop) {
+ cmd = new(Stop)
+ cmd.network = network
+ return
+}
+
+func NewInvokeStart(network *net.Network) (cmd *Start) {
+ cmd = new(Start)
+ cmd.network = network
+ return
+}
+
+func NewInvokeRestart(network *net.Network) (cmd *Restart) {
+ cmd = new(Restart)
+ cmd.network = network
+ return
+}
+
+var paramFlags = []cli.Flag{
+ cli.StringSliceFlag{
+ Name: "param, P",
+ Usage: "Parameter and value separated by '=', e.g. -P x=y. If the parameter value is complex or multi-" +
+ "lined it may be provided in a file and referenced as: '@<file>', e.g. -P x=@/path/to/file.",
+ },
+}
+
+func (cmd *Invoke) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "invoke",
+ Description: "Invoke an effector of an application and entity",
+ Usage: "BROOKLYN_NAME EFF-SCOPE invoke [ parameter-options ]",
+ Flags: paramFlags,
+ }
+}
+
+func (cmd *Stop) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "stop",
+ Description: "Invoke stop effector on an application and entity",
+ Usage: "BROOKLYN_NAME ENT-SCOPE stop [ parameter-options ]",
+ Flags: paramFlags,
+ }
+}
+
+func (cmd *Start) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "start",
+ Description: "Invoke start effector on an application and entity",
+ Usage: "BROOKLYN_NAME ENT-SCOPE start [ parameter-options ]",
+ Flags: paramFlags,
+ }
+}
+
+func (cmd *Restart) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "restart",
+ Description: "Invoke restart effector on an application and entity",
+ Usage: "BROOKLYN_NAME ENT-SCOPE restart [ parameter-options ]",
+ Flags: paramFlags,
+ }
+}
+
+func (cmd *Invoke) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ parms := c.StringSlice("param")
+ invoke(cmd.network, scope.Application, scope.Entity, scope.Effector, parms)
+}
+
+const stopEffector = "stop"
+
+func (cmd *Stop) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ parms := c.StringSlice("param")
+ invoke(cmd.network, scope.Application, scope.Entity, stopEffector, parms)
+}
+
+const startEffector = "start"
+
+func (cmd *Start) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ parms := c.StringSlice("param")
+ invoke(cmd.network, scope.Application, scope.Entity, startEffector, parms)
+}
+
+const restartEffector = "restart"
+
+func (cmd *Restart) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ parms := c.StringSlice("param")
+ invoke(cmd.network, scope.Application, scope.Entity, restartEffector, parms)
+}
+
+func invoke(network *net.Network, application, entity, effector string, parms []string) {
+ names, vals, err := extractParams(parms)
+ result, err := entity_effectors.TriggerEffector(network, application, entity, effector, names, vals)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ } else {
+ if "" != result {
+ fmt.Println(result)
+ }
+ }
+}
+
+func extractParams(parms []string) ([]string, []string, error) {
+ names := make([]string, len(parms))
+ vals := make([]string, len(parms))
+ var err error
+ for i, parm := range parms {
+ index := strings.Index(parm, "=")
+ if index < 0 {
+ return names, vals, errors.New("Parameter value not provided: " + parm)
+ }
+ names[i] = parm[0:index]
+ vals[i], err = extractParamValue(parm[index+1:])
+ }
+ return names, vals, err
+}
+
+const paramDataPrefix string = "@"
+
+func extractParamValue(rawParam string) (string, error) {
+ var err error
+ var val string
+ if strings.HasPrefix(rawParam, paramDataPrefix) {
+ // strip the data prefix from the filename before reading
+ val, err = readParamFromFile(rawParam[len(paramDataPrefix):])
+ } else {
+ val = rawParam
+ err = nil
+ }
+ return val, err
+}
+
+// returning a string rather than byte array, assuming non-binary
+// TODO - if necessary support binary data sending to effector
+func readParamFromFile(filename string) (string, error) {
+ dat, err := ioutil.ReadFile(filename)
+ return string(dat), err
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/list.go
----------------------------------------------------------------------
diff --git a/cli/commands/list.go b/cli/commands/list.go
new file mode 100644
index 0000000..7758568
--- /dev/null
+++ b/cli/commands/list.go
@@ -0,0 +1,90 @@
+/*
+ * 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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/command"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+ "strings"
+)
+
+type List struct {
+ network *net.Network
+ listCommands map[string]command.Command
+}
+
+func NewList(network *net.Network) (cmd *List) {
+ cmd = new(List)
+ cmd.network = network
+ cmd.listCommands = map[string]command.Command{
+ // ListApplicationCommand: NewApplications(cmd.network),
+ // ListEntityCommand: NewEntities(cmd.network),
+ // ListSensorCommand: NewSensors(cmd.network),
+ // ListEffectorCommand: NewEffector(cmd.network),
+ }
+ return
+}
+
+const ListApplicationCommand = "application"
+const ListEntityCommand = "entities"
+const ListSensorCommand = "sensors"
+const ListEffectorCommand = "effectors"
+
+var listCommands = []string{
+ ListApplicationCommand,
+ ListEntityCommand,
+ ListSensorCommand,
+ ListEffectorCommand,
+}
+var listCommandsUsage = strings.Join(listCommands, " | ")
+
+func (cmd *List) SubCommandNames() []string {
+ return listCommands
+}
+
+func (cmd *List) SubCommand(name string) command.Command {
+ return cmd.listCommands[name]
+}
+
+func (cmd *List) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "list",
+ Description: "List details for a variety of operands",
+ Usage: "BROOKLYN_NAME SCOPE list (" + listCommandsUsage + ")",
+ Flags: []cli.Flag{},
+ Operands: []command_metadata.CommandMetadata{
+ cmd.SubCommand(ListApplicationCommand).Metadata(),
+ cmd.SubCommand(ListEntityCommand).Metadata(),
+ cmd.SubCommand(ListSensorCommand).Metadata(),
+ cmd.SubCommand(ListEffectorCommand).Metadata(),
+ },
+ }
+}
+
+func (cmd *List) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Printf("Unrecognised item for list, please use one of (%s)\n", listCommandsUsage)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/locations.go
----------------------------------------------------------------------
diff --git a/cli/commands/locations.go b/cli/commands/locations.go
new file mode 100644
index 0000000..f197130
--- /dev/null
+++ b/cli/commands/locations.go
@@ -0,0 +1,63 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/api/locations"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/urfave/cli"
+)
+
+type Locations struct {
+ network *net.Network
+}
+
+func NewLocations(network *net.Network) (cmd *Locations) {
+ cmd = new(Locations)
+ cmd.network = network
+ return
+}
+
+func (cmd *Locations) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "locations",
+ Description: "* List the available locations",
+ Usage: "BROOKLYN_NAME locations",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Locations) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ locationList, err := locations.LocationList(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Name", "Spec"})
+ for _, location := range locationList {
+ table.Add(location.Id, location.Name, location.Spec)
+ }
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/login.go
----------------------------------------------------------------------
diff --git a/cli/commands/login.go b/cli/commands/login.go
new file mode 100644
index 0000000..df63b33
--- /dev/null
+++ b/cli/commands/login.go
@@ -0,0 +1,113 @@
+/*
+ * 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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/version"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "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"
+ "github.com/urfave/cli"
+ "golang.org/x/crypto/ssh/terminal"
+ "syscall"
+)
+
+type Login struct {
+ network *net.Network
+ config *io.Config
+}
+
+func NewLogin(network *net.Network, config *io.Config) (cmd *Login) {
+ cmd = new(Login)
+ cmd.network = network
+ cmd.config = config
+ return
+}
+
+func (cmd *Login) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "login",
+ Description: "Login to brooklyn",
+ Usage: "BROOKLYN_NAME login URL [USER [PASSWORD]]",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Login) Run(scope scope.Scope, c *cli.Context) {
+ if !c.Args().Present() {
+ error_handler.ErrorExit("A URL must be provided as the first argument", error_handler.CLIUsageErrorExitCode)
+ }
+
+ // If an argument was not supplied, it is set to empty string
+ cmd.network.BrooklynUrl = c.Args().Get(0)
+ cmd.network.BrooklynUser = c.Args().Get(1)
+ cmd.network.BrooklynPass = c.Args().Get(2)
+ cmd.network.SkipSslChecks = c.GlobalBool("skipSslChecks")
+
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+
+ // Strip off trailing '/' from URL if present.
+ if cmd.network.BrooklynUrl[len(cmd.network.BrooklynUrl)-1] == '/' {
+ if len(cmd.network.BrooklynUrl) == 1 {
+ error_handler.ErrorExit("URL must not be a single \"/\" character", error_handler.CLIUsageErrorExitCode)
+ }
+ cmd.network.BrooklynUrl = cmd.network.BrooklynUrl[0 : len(cmd.network.BrooklynUrl)-1]
+ }
+
+ // Prompt for password if not supplied (password is not echoed to screen
+ if cmd.network.BrooklynUser != "" && cmd.network.BrooklynPass == "" {
+ fmt.Print("Enter Password: ")
+ bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
+ if err != nil {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Printf("\n")
+ cmd.network.BrooklynPass = string(bytePassword)
+ }
+
+ if cmd.config.Map == nil {
+ cmd.config.Map = make(map[string]interface{})
+ }
+ // now persist these credentials to the yaml file
+ auth, ok := cmd.config.Map["auth"].(map[string]interface{})
+ if !ok {
+ auth = make(map[string]interface{})
+ cmd.config.Map["auth"] = auth
+ }
+
+ auth[cmd.network.BrooklynUrl] = map[string]string{
+ "username": cmd.network.BrooklynUser,
+ "password": cmd.network.BrooklynPass,
+ }
+
+ cmd.config.Map["target"] = cmd.network.BrooklynUrl
+ cmd.config.Map["skipSslChecks"] = cmd.network.SkipSslChecks
+ cmd.config.Write()
+
+ loginVersion, err := version.Version(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Printf("Connected to Brooklyn version %s at %s\n", loginVersion.Version, cmd.network.BrooklynUrl)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/policy.go
----------------------------------------------------------------------
diff --git a/cli/commands/policy.go b/cli/commands/policy.go
new file mode 100644
index 0000000..1d587fd
--- /dev/null
+++ b/cli/commands/policy.go
@@ -0,0 +1,114 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/api/entity_policies"
+ "github.com/apache/brooklyn-client/api/entity_policy_config"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/urfave/cli"
+ "sort"
+)
+
+type Policy struct {
+ network *net.Network
+}
+
+type policyConfigList []models.PolicyConfigList
+
+// Len is the number of elements in the collection.
+func (configs policyConfigList) Len() int {
+ return len(configs)
+}
+
+// Less reports whether the element with
+// index i should sort before the element with index j.
+func (configs policyConfigList) Less(i, j int) bool {
+ return configs[i].Name < configs[j].Name
+}
+
+// Swap swaps the elements with indexes i and j.
+func (configs policyConfigList) Swap(i, j int) {
+ temp := configs[i]
+ configs[i] = configs[j]
+ configs[j] = temp
+}
+
+func NewPolicy(network *net.Network) (cmd *Policy) {
+ cmd = new(Policy)
+ cmd.network = network
+ return
+}
+
+func (cmd *Policy) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "policy",
+ Aliases: []string{"policies", "pol", "pols"},
+ Description: "Show the policies for an application or entity",
+ Usage: "BROOKLYN_NAME SCOPE policy [NAME]",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Policy) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ if c.Args().Present() {
+ cmd.show(scope.Application, scope.Entity, c.Args().First())
+ } else {
+ cmd.list(scope.Application, scope.Entity)
+ }
+}
+
+func (cmd *Policy) show(application, entity, policy string) {
+ configs, err := entity_policy_config.GetAllConfigValues(cmd.network, application, entity, policy)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Name", "Value", "Description"})
+ var theConfigs policyConfigList = configs
+ sort.Sort(theConfigs)
+
+ for _, config := range theConfigs {
+ value, err := entity_policy_config.GetConfigValue(cmd.network, application, entity, policy, config.Name)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table.Add(config.Name, value, config.Description)
+ }
+ table.Print()
+}
+
+func (cmd *Policy) list(application, entity string) {
+ policies, err := entity_policies.PolicyList(cmd.network, application, entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Name", "State"})
+ for _, policy := range policies {
+ table.Add(policy.Id, policy.Name, string(policy.State))
+ }
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/rename.go
----------------------------------------------------------------------
diff --git a/cli/commands/rename.go b/cli/commands/rename.go
new file mode 100644
index 0000000..7891971
--- /dev/null
+++ b/cli/commands/rename.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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entities"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type Rename struct {
+ network *net.Network
+}
+
+func NewRename(network *net.Network) (cmd *Rename) {
+ cmd = new(Rename)
+ cmd.network = network
+ return
+}
+
+func (cmd *Rename) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "rename",
+ Description: "Rename an application or entity",
+ Usage: "BROOKLYN_NAME SCOPE rename NEW_NAME",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Rename) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ rename, err := entities.Rename(cmd.network, scope.Application, scope.Entity, c.Args().First())
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(rename)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/reset-catalog.go
----------------------------------------------------------------------
diff --git a/cli/commands/reset-catalog.go b/cli/commands/reset-catalog.go
new file mode 100644
index 0000000..6830399
--- /dev/null
+++ b/cli/commands/reset-catalog.go
@@ -0,0 +1,33 @@
+/*
+ * 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 commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type ResetCatalog struct {
+ network *net.Network
+}
+
+func NewResetCatalog(network *net.Network) (cmd *ResetCatalog) {
+ cmd = new(ResetCatalog)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/sensor.go
----------------------------------------------------------------------
diff --git a/cli/commands/sensor.go b/cli/commands/sensor.go
new file mode 100644
index 0000000..ac75660
--- /dev/null
+++ b/cli/commands/sensor.go
@@ -0,0 +1,118 @@
+/*
+ * 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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entity_sensors"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/urfave/cli"
+ "sort"
+)
+
+type Sensor struct {
+ network *net.Network
+}
+
+type sensorList []models.SensorSummary
+
+// Len is the number of elements in the collection.
+func (sensors sensorList) Len() int {
+ return len(sensors)
+}
+
+// Less reports whether the element with
+// index i should sort before the element with index j.
+func (sensors sensorList) Less(i, j int) bool {
+ return sensors[i].Name < sensors[j].Name
+}
+
+// Swap swaps the elements with indexes i and j.
+func (sensors sensorList) Swap(i, j int) {
+ temp := sensors[i]
+ sensors[i] = sensors[j]
+ sensors[j] = temp
+}
+
+func NewSensor(network *net.Network) (cmd *Sensor) {
+ cmd = new(Sensor)
+ cmd.network = network
+ return
+}
+
+func (cmd *Sensor) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "sensor",
+ Description: "Show values of all sensors or named sensor for an application or entity",
+ Usage: "BROOKLYN_NAME SCOPE sensor [ SENSOR_NAME ]",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Sensor) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ if c.Args().Present() {
+ cmd.show(scope.Application, scope.Entity, c.Args().First())
+ } else {
+ cmd.list(scope.Application, scope.Entity)
+ }
+}
+
+func (cmd *Sensor) show(application, entity, sensor string) {
+ sensorValue, err := entity_sensors.SensorValue(cmd.network, application, entity, sensor)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ displayValue, err := stringRepresentation(sensorValue)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(displayValue)
+}
+
+func (cmd *Sensor) list(application, entity string) {
+ sensors, err := entity_sensors.SensorList(cmd.network, application, entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ var theSensors sensorList = sensors
+ table := terminal.NewTable([]string{"Name", "Description", "Value"})
+
+ sort.Sort(theSensors)
+
+ for _, sensor := range theSensors {
+ value, err := entity_sensors.SensorValue(cmd.network, application, entity, sensor.Name)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ displayValue, err := stringRepresentation(value)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table.Add(sensor.Name, sensor.Description, displayValue)
+ }
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/set.go
----------------------------------------------------------------------
diff --git a/cli/commands/set.go b/cli/commands/set.go
new file mode 100644
index 0000000..ae1a594
--- /dev/null
+++ b/cli/commands/set.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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entity_config"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type SetConfig struct {
+ network *net.Network
+}
+
+func NewSetConfig(network *net.Network) (cmd *SetConfig) {
+ cmd = new(SetConfig)
+ cmd.network = network
+ return
+}
+
+func (cmd *SetConfig) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "set",
+ Description: "Set config for an entity",
+ Usage: "BROOKLYN_NAME CONFIG-SCOPE set VALUE",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *SetConfig) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ response, err := entity_config.SetConfig(cmd.network, scope.Application, scope.Entity, scope.Config, c.Args().First())
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(response)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/spec.go
----------------------------------------------------------------------
diff --git a/cli/commands/spec.go b/cli/commands/spec.go
new file mode 100644
index 0000000..06819b9
--- /dev/null
+++ b/cli/commands/spec.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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entities"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type Spec struct {
+ network *net.Network
+}
+
+func NewSpec(network *net.Network) (cmd *Spec) {
+ cmd = new(Spec)
+ cmd.network = network
+ return
+}
+
+func (cmd *Spec) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "spec",
+ Description: "Get the YAML spec used to create the entity, if available",
+ Usage: "BROOKLYN_NAME SCOPE spec",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Spec) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ spec, err := entities.Spec(cmd.network, scope.Application, scope.Entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(spec)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/start-policy.go
----------------------------------------------------------------------
diff --git a/cli/commands/start-policy.go b/cli/commands/start-policy.go
new file mode 100644
index 0000000..68dbec7
--- /dev/null
+++ b/cli/commands/start-policy.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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entity_policies"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type StartPolicy struct {
+ network *net.Network
+}
+
+func NewStartPolicy(network *net.Network) (cmd *StartPolicy) {
+ cmd = new(StartPolicy)
+ cmd.network = network
+ return
+}
+
+func (cmd *StartPolicy) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "start-policy",
+ Description: "Start or resume a policy",
+ Usage: "BROOKLYN_NAME SCOPE start-policy POLICY",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *StartPolicy) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ spec, err := entity_policies.StartPolicy(cmd.network, scope.Application, scope.Entity, c.Args().First())
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(spec)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/stop-policy.go
----------------------------------------------------------------------
diff --git a/cli/commands/stop-policy.go b/cli/commands/stop-policy.go
new file mode 100644
index 0000000..2700802
--- /dev/null
+++ b/cli/commands/stop-policy.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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entity_policies"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type StopPolicy struct {
+ network *net.Network
+}
+
+func NewStopPolicy(network *net.Network) (cmd *StopPolicy) {
+ cmd = new(StopPolicy)
+ cmd.network = network
+ return
+}
+
+func (cmd *StopPolicy) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "stop-policy",
+ Description: "Suspends a policy",
+ Usage: "BROOKLYN_NAME SCOPE stop-policy POLICY",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *StopPolicy) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ spec, err := entity_policies.StopPolicy(cmd.network, scope.Application, scope.Entity, c.Args().First())
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(spec)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/tree.go
----------------------------------------------------------------------
diff --git a/cli/commands/tree.go b/cli/commands/tree.go
new file mode 100644
index 0000000..5665997
--- /dev/null
+++ b/cli/commands/tree.go
@@ -0,0 +1,78 @@
+/*
+ * 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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/application"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type Tree struct {
+ network *net.Network
+}
+
+func NewTree(network *net.Network) (cmd *Tree) {
+ cmd = new(Tree)
+ cmd.network = network
+ return
+}
+
+func (cmd *Tree) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "tree",
+ Description: "* Show the tree of all applications",
+ Usage: "BROOKLYN_NAME tree",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Tree) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ trees, err := application.Tree(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ cmd.printTrees(trees, "")
+}
+
+func (cmd *Tree) printTrees(trees []models.Tree, indent string) {
+ for i, app := range trees {
+ cmd.printTree(app, indent, i == len(trees)-1)
+ }
+}
+
+func (cmd *Tree) printTree(tree models.Tree, indent string, last bool) {
+ fmt.Println(indent+"|-", tree.Name)
+ fmt.Println(indent+"+-", tree.Type)
+
+ if last {
+ indent = indent + " "
+ } else {
+ indent = indent + "| "
+ }
+ cmd.printTrees(tree.Children, indent)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/utils.go
----------------------------------------------------------------------
diff --git a/cli/commands/utils.go b/cli/commands/utils.go
new file mode 100644
index 0000000..a4533b1
--- /dev/null
+++ b/cli/commands/utils.go
@@ -0,0 +1,38 @@
+/*
+ * 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 commands
+
+import (
+ "encoding/json"
+)
+
+func stringRepresentation(value interface{}) (string, error) {
+ var result string
+ switch value.(type) {
+ case string:
+ result = value.(string) // use string value as-is
+ default:
+ json, err := json.Marshal(value)
+ if err != nil {
+ return "", err
+ }
+ result = string(json) // return JSON text representation of value object
+ }
+ return result, nil
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/commands/version.go
----------------------------------------------------------------------
diff --git a/cli/commands/version.go b/cli/commands/version.go
new file mode 100644
index 0000000..39de4b6
--- /dev/null
+++ b/cli/commands/version.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 commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/version"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/urfave/cli"
+)
+
+type Version struct {
+ network *net.Network
+}
+
+func NewVersion(network *net.Network) (cmd *Version) {
+ cmd = new(Version)
+ cmd.network = network
+ return
+}
+
+func (cmd *Version) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "version",
+ Description: "Display the version of the connected Brooklyn",
+ Usage: "BROOKLYN_NAME version",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Version) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ version, err := version.Version(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(version.Version)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/error_handler/error.go
----------------------------------------------------------------------
diff --git a/cli/error_handler/error.go b/cli/error_handler/error.go
new file mode 100644
index 0000000..8238c2b
--- /dev/null
+++ b/cli/error_handler/error.go
@@ -0,0 +1,46 @@
+/*
+ * 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 error_handler
+
+import (
+ "fmt"
+ "os"
+)
+
+const CLIUsageErrorExitCode int = 1
+const CliGenericErrorExitCode int = 2
+const CLITrapErrorCode int = 3
+
+func ErrorExit(errorvalue interface{}, errorcode ...int) {
+ switch errorvalue.(type) {
+ case error:
+ fmt.Fprintln(os.Stderr, errorvalue)
+ case string:
+ fmt.Fprintln(os.Stderr, errorvalue)
+ case nil:
+ fmt.Fprintln(os.Stderr, "No error message provided")
+ default:
+ fmt.Fprintln(os.Stderr, "Unknown Error Type: ", errorvalue)
+ }
+ if len(errorcode) > 0 {
+ os.Exit(errorcode[0])
+ } else {
+ os.Exit(CliGenericErrorExitCode)
+ }
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/glide.lock
----------------------------------------------------------------------
diff --git a/cli/glide.lock b/cli/glide.lock
new file mode 100644
index 0000000..f214d4c
--- /dev/null
+++ b/cli/glide.lock
@@ -0,0 +1,10 @@
+hash: 1d87d5643857ae47cd40cc29e7b9b813198980c84b3491376b3561c467e37994
+updated: 2016-06-02T21:50:02.953614402+01:00
+imports:
+- name: github.com/urfave/cli
+ version: 5db74198dee1cfe60cf06a611d03a420361baad6
+- name: golang.org/x/crypto
+ version: 1f22c0103821b9390939b6776727195525381532
+ subpackages:
+ - ssh/terminal
+devImports: []
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/glide.yaml
----------------------------------------------------------------------
diff --git a/cli/glide.yaml b/cli/glide.yaml
new file mode 100644
index 0000000..e2cf5c9
--- /dev/null
+++ b/cli/glide.yaml
@@ -0,0 +1,6 @@
+package: github.com/apache/brooklyn-client
+import:
+- package: github.com/urfave/cli
+- package: golang.org/x/crypto
+ subpackages:
+ - ssh/terminal
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/io/config.go
----------------------------------------------------------------------
diff --git a/cli/io/config.go b/cli/io/config.go
new file mode 100644
index 0000000..ea9ca01
--- /dev/null
+++ b/cli/io/config.go
@@ -0,0 +1,72 @@
+/*
+ * 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 io
+
+import (
+ "encoding/json"
+ "os"
+ "path/filepath"
+
+ "github.com/apache/brooklyn-client/error_handler"
+)
+
+type Config struct {
+ FilePath string
+ Map map[string]interface{}
+}
+
+func GetConfig() (config *Config) {
+ // check to see if $BRCLI_HOME/.brooklyn_cli or $HOME/.brooklyn_cli exists
+ // Then parse it to get user credentials
+ config = new(Config)
+ if os.Getenv("BRCLI_HOME") != "" {
+ config.FilePath = filepath.Join(os.Getenv("BRCLI_HOME"), ".brooklyn_cli")
+ } else {
+ config.FilePath = filepath.Join(os.Getenv("HOME"), ".brooklyn_cli")
+ }
+ if _, err := os.Stat(config.FilePath); os.IsNotExist(err) {
+ config.Map = make(map[string]interface{})
+ config.Write()
+ }
+ config.Read()
+ return
+}
+
+func (config *Config) Write() {
+ // Create file as read/write by user (but does not change perms of existing file)
+ fileToWrite, err := os.OpenFile(config.FilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
+ if err != nil {
+ error_handler.ErrorExit(err)
+ }
+ defer fileToWrite.Close()
+
+ enc := json.NewEncoder(fileToWrite)
+ enc.Encode(config.Map)
+}
+
+func (config *Config) Read() {
+ fileToRead, err := os.Open(config.FilePath)
+ if err != nil {
+ error_handler.ErrorExit(err)
+ }
+ defer fileToRead.Close()
+
+ dec := json.NewDecoder(fileToRead)
+ dec.Decode(&config.Map)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/models/access.go
----------------------------------------------------------------------
diff --git a/cli/models/access.go b/cli/models/access.go
new file mode 100644
index 0000000..7fbdcbf
--- /dev/null
+++ b/cli/models/access.go
@@ -0,0 +1,24 @@
+/*
+ * 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 models
+
+type AccessSummary struct {
+ Links map[string]URI `json:"links"`
+ LocationProvisioningAllowed bool `json:"locationProvisioningAllowed"`
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/models/applications.go
----------------------------------------------------------------------
diff --git a/cli/models/applications.go b/cli/models/applications.go
new file mode 100644
index 0000000..aa44b8d
--- /dev/null
+++ b/cli/models/applications.go
@@ -0,0 +1,97 @@
+/*
+ * 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 models
+
+type Tree struct {
+ Id string `json:"id"`
+ ParentId string `json:"parentId"`
+ Name string `json:"name"`
+ Type string `json:"type"`
+ CatalogItemId string `json:"catalogItemId"`
+ Children []Tree `json:"children"`
+ GroupIds []string `json:"groupIds"`
+ Members []string `json:"members"`
+}
+
+type TaskSummary struct {
+ SubmitTimeUtc int64 `json:"submitTimeUtc"`
+ EndTimeUtc int64 `json:"endTimeUtc"`
+ IsCancelled bool `json:"isCancelled"`
+ CurrentStatus string `json:"currentStatus"`
+ BlockingTask LinkTaskWithMetadata `json:"blockingTask"`
+ DisplayName string `json:"displayName"`
+ Streams map[string]LinkStreamsWithMetadata `json:"streams"`
+ Description string `json:"description"`
+ EntityId string `json:"entityId"`
+ EntityDisplayName string `json:"entityDisplayName"`
+ Error bool `json:"error"`
+ SubmittedByTask LinkTaskWithMetadata `json:"submittedByTask"`
+ Result interface{} `json:"result"`
+ IsError bool `json:"isError"`
+ DetailedStatus string `json:"detailedStatus"`
+ Children []LinkTaskWithMetadata `json:"children"`
+ BlockingDetails string `json:"blockingDetails"`
+ Cancelled bool `json:"cancelled"`
+ Links map[string]URI `json:"links"`
+ Id string `json:"id"`
+ StartTimeUtc int64 `json:"startTimeUtc"`
+}
+
+type ApplicationSummary struct {
+ Links map[string]URI `json:"links"`
+ Id string `json:"id"`
+ Spec ApplicationSpec `json:"spec"`
+ Status Status `json:"status"`
+}
+
+type ApplicationSpec struct {
+ Name string `json:"name"`
+ Type string `json:"type"`
+ Locations []string `json:"locations"`
+}
+
+type Status string
+
+type LinkWithMetadata struct {
+}
+
+type LinkStreamsWithMetadata struct {
+ Link string `json:"link"`
+ Metadata LinkStreamMetadata `json:"metadata"`
+}
+
+type LinkStreamMetadata struct {
+ Name string `json:"name"`
+ Size int64 `json:"size"`
+ SizeText string `json:"sizeText"`
+}
+
+type LinkTaskWithMetadata struct {
+ Link string `json:"link"`
+ Metadata LinkTaskMetadata `json:"metadata"`
+}
+
+type LinkTaskMetadata struct {
+ Id string `json:"id"`
+ TaskName string `json:"taskName"`
+ EntityId string `json:"entityId"`
+ EntityDisplayName string `json:"entityDisplayName"`
+}
+
+type URI string
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/models/catalog.go
----------------------------------------------------------------------
diff --git a/cli/models/catalog.go b/cli/models/catalog.go
new file mode 100644
index 0000000..ef6dabf
--- /dev/null
+++ b/cli/models/catalog.go
@@ -0,0 +1,63 @@
+/*
+ * 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 models
+
+type CatalogItemSummary struct {
+ Name string `json:"name"`
+ JavaType string `json:"javaType"`
+ SymbolicName string `json:"symbolicName"`
+ Version string `json:"version"`
+ PlanYaml string `json:"planYaml"`
+ Description string `json:"description"`
+ Deprecated bool `json:"deprecated"`
+ Links map[string]interface{} `json:"links"`
+ Id string `json:"id"`
+ Type string `json:"type"`
+}
+
+type CatalogPolicySummary struct {
+ symbolicName string `json:"symbolicName"`
+ version string `json:"version"`
+ displayName string `json:"name"`
+ javaType string `json:"javaType"`
+ planYaml string `json:"planYaml"`
+ description string `json:"description"`
+ iconUrl string `json:"iconUrl"`
+ deprecated bool `json:"deprecated"`
+ links map[string]URI `json:"links"`
+}
+
+type CatalogLocationSummary struct {
+}
+
+type CatalogEntitySummary struct {
+ symbolicName string `json:"symbolicName"`
+ version string `json:"version"`
+ displayName string `json:"name"`
+ javaType string `json:"javaType"`
+ planYaml string `json:"planYaml"`
+ description string `json:"description"`
+ Config []ConfigSummary `json:"config"`
+ Effectors []EffectorSummary `json:"effectors"`
+ Sensors []SensorSummary `json:"sensors"`
+ Deprecated bool `json:"deprecated"`
+ Links map[string]interface{} `json:"links"`
+ Id string `json:"id"`
+ Type string `json:"type"`
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/models/config.go
----------------------------------------------------------------------
diff --git a/cli/models/config.go b/cli/models/config.go
new file mode 100644
index 0000000..bc97650
--- /dev/null
+++ b/cli/models/config.go
@@ -0,0 +1,31 @@
+/*
+ * 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 models
+
+type ConfigSummary struct {
+ Reconfigurable bool `json:"reconfigurable"`
+ PossibleValues []map[string]string `json:"possibleValues"`
+ DefaultValue interface{} `json:"defaultValue"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Links map[string]URI `json:"links"`
+ Label string `json:"label"`
+ Priority float64 `json:"priority"`
+ Type string `json:"type"`
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/models/effectors.go
----------------------------------------------------------------------
diff --git a/cli/models/effectors.go b/cli/models/effectors.go
new file mode 100644
index 0000000..1b846b7
--- /dev/null
+++ b/cli/models/effectors.go
@@ -0,0 +1,34 @@
+/*
+ * 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 models
+
+type EffectorSummary struct {
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Links map[string]URI `json:"links"`
+ Parameters []ParameterSummary `json:"parameters"`
+ ReturnType string `json:"returnType"`
+}
+
+type ParameterSummary struct {
+ Name string `json:"name"`
+ Type string `json:"type"`
+ Description string `json:"description"`
+ DefaultValue interface{} `json:"defaultValue"`
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/models/entities.go
----------------------------------------------------------------------
diff --git a/cli/models/entities.go b/cli/models/entities.go
new file mode 100644
index 0000000..fdb85dc
--- /dev/null
+++ b/cli/models/entities.go
@@ -0,0 +1,27 @@
+/*
+ * 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 models
+
+type EntitySummary struct {
+ CatalogItemId string `json:"catalogItemId"`
+ Name string `json:"name"`
+ Links map[string]URI `json:"links"`
+ Id string `json:"id"`
+ Type string `json:"type"`
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/models/locations.go
----------------------------------------------------------------------
diff --git a/cli/models/locations.go b/cli/models/locations.go
new file mode 100644
index 0000000..2505eae
--- /dev/null
+++ b/cli/models/locations.go
@@ -0,0 +1,28 @@
+/*
+ * 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 models
+
+type LocationSummary struct {
+ Id string `json:"id"`
+ Name string `json:"name"`
+ Spec string `json:"spec"`
+ Type string `json:"type"`
+ Config map[string]interface{} `json:"config"`
+ Links map[string]URI `json:"links"`
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/models/policies.go
----------------------------------------------------------------------
diff --git a/cli/models/policies.go b/cli/models/policies.go
new file mode 100644
index 0000000..fca9298
--- /dev/null
+++ b/cli/models/policies.go
@@ -0,0 +1,39 @@
+/*
+ * 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 models
+
+type PolicySummary struct {
+ CatalogItemId string `json:"catalogItemId"`
+ Name string `json:"name"`
+ Links map[string]URI `json:"links"`
+ Id string `json:"id"`
+ State Status `json:"state"`
+}
+
+type PolicyConfigList struct {
+ Name string `json:"name"`
+ Type string `json:"type"`
+ DefaultValue interface{} `json:"defaultValue`
+ Description string `json:"description"`
+ Reconfigurable bool `json:"reconfigurable"`
+ Label string `json:"label"`
+ Priority int64 `json:"priority"`
+ PossibleValues []interface{} `json:"possibleValues"`
+ Links map[string]URI `json:"links"`
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/models/sensors.go
----------------------------------------------------------------------
diff --git a/cli/models/sensors.go b/cli/models/sensors.go
new file mode 100644
index 0000000..67b3b4f
--- /dev/null
+++ b/cli/models/sensors.go
@@ -0,0 +1,26 @@
+/*
+ * 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 models
+
+type SensorSummary struct {
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Links map[string]URI `json:"links"`
+ Type string `json:"type"`
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/models/version.go
----------------------------------------------------------------------
diff --git a/cli/models/version.go b/cli/models/version.go
new file mode 100644
index 0000000..8f12a67
--- /dev/null
+++ b/cli/models/version.go
@@ -0,0 +1,34 @@
+/*
+ * 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 models
+
+type VersionSummary struct {
+ Version string `json:"version"`
+ BuildSha1 string `json:"buildSha1"`
+ BuildBranch string `json:"buildBranch"`
+ Features []BrooklynFeatureSummary `json:"features"`
+}
+
+type BrooklynFeatureSummary struct {
+ Name string `json:"name"`
+ SymbolicName string `json:"symbolicName"`
+ Version string `json:"version"`
+ LastModified string `json:"lastModified"`
+ AdditionalData map[string]string `json:"additionalData"`
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/net/net.go
----------------------------------------------------------------------
diff --git a/cli/net/net.go b/cli/net/net.go
new file mode 100644
index 0000000..b35a6c3
--- /dev/null
+++ b/cli/net/net.go
@@ -0,0 +1,211 @@
+/*
+ * 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 net
+
+import (
+ "bytes"
+ "encoding/json"
+ "errors"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "net/url"
+ "os"
+ "path/filepath"
+ "strconv"
+ "strings"
+ "crypto/tls"
+)
+
+type Network struct {
+ BrooklynUrl string
+ BrooklynUser string
+ BrooklynPass string
+ SkipSslChecks bool
+}
+
+func NewNetwork(brooklynUrl, brooklynUser, brooklynPass string, skipSslChecks bool) (net *Network) {
+ net = new(Network)
+ net.BrooklynUrl = brooklynUrl
+ net.BrooklynUser = brooklynUser
+ net.BrooklynPass = brooklynPass
+ net.SkipSslChecks = skipSslChecks
+ return
+}
+
+func (net *Network) NewRequest(method, path string, body io.Reader) *http.Request {
+ req, _ := http.NewRequest(method, net.BrooklynUrl+path, body)
+ req.SetBasicAuth(net.BrooklynUser, net.BrooklynPass)
+ return req
+}
+
+func (net *Network) NewGetRequest(url string) *http.Request {
+ return net.NewRequest("GET", url, nil)
+}
+
+func (net *Network) NewPostRequest(url string, body io.Reader) *http.Request {
+ return net.NewRequest("POST", url, body)
+}
+
+func (net *Network) NewDeleteRequest(url string) *http.Request {
+ return net.NewRequest("DELETE", url, nil)
+}
+
+type HttpError struct {
+ Code int
+ Status string
+ Headers http.Header
+ Body string
+}
+
+func (err HttpError) Error() string {
+ return err.Status
+}
+
+func makeError(resp *http.Response, code int, body []byte) error {
+ theError := HttpError{
+ Code: code,
+ Status: resp.Status,
+ Headers: resp.Header,
+ }
+ details := make(map[string]string)
+ if err := json.Unmarshal(body, &details); nil == err {
+ if message, ok := details["message"]; ok {
+ theError.Body = message
+ return theError
+ }
+ }
+ theError.Body = string(body)
+ return theError
+}
+
+func (net *Network) SendRequest(req *http.Request) ([]byte, error) {
+ tr := &http.Transport{
+ TLSClientConfig: &tls.Config{InsecureSkipVerify: net.SkipSslChecks},
+ }
+ client := &http.Client{Transport: tr}
+ resp, err := client.Do(req)
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+ body, err := ioutil.ReadAll(resp.Body)
+ if code, failed := unsuccessful(resp.Status); failed {
+ return nil, makeError(resp, code, body)
+ }
+ return body, err
+}
+
+const httpSuccessSeriesFrom = 200
+const httpSuccessSeriesTo = 300
+
+func unsuccessful(status string) (int, bool) {
+ tokens := strings.Split(status, " ")
+ if 0 == len(tokens) {
+ return -1, false
+ }
+ code, err := strconv.Atoi(tokens[0])
+ if nil != err {
+ return -1, false
+ }
+ return code, code < httpSuccessSeriesFrom || httpSuccessSeriesTo <= code
+}
+
+func (net *Network) SendGetRequest(url string) ([]byte, error) {
+ req := net.NewGetRequest(url)
+ req.Header.Set("Accept", "application/json, text/plain")
+ body, err := net.SendRequest(req)
+ return body, err
+}
+
+func (net *Network) SendDeleteRequest(url string) ([]byte, error) {
+ req := net.NewDeleteRequest(url)
+ body, err := net.SendRequest(req)
+ return body, err
+}
+
+func (net *Network) SendEmptyPostRequest(url string) ([]byte, error) {
+ req := net.NewPostRequest(url, nil)
+ body, err := net.SendRequest(req)
+ return body, err
+}
+
+func (net *Network) SendPostRequest(urlStr string, data []byte) ([]byte, error) {
+ req := net.NewPostRequest(urlStr, bytes.NewBuffer(data))
+ req.Header.Set("Content-Type", "application/json")
+ body, err := net.SendRequest(req)
+ return body, err
+}
+
+func (net *Network) SendPostResourceRequest(restUrl string, resourceUrl string, contentType string) ([]byte, error) {
+ resource, err := openResource(resourceUrl)
+ defer resource.Close()
+ req := net.NewPostRequest(restUrl, resource)
+ req.Header.Set("Content-Type", contentType)
+ body, err := net.SendRequest(req)
+ return body, err
+}
+
+func openResource(resourceUrl string) (io.ReadCloser, error) {
+ u, err := url.Parse(resourceUrl)
+ if err != nil {
+ return nil, err
+ }
+ if "" == u.Scheme || "file" == u.Scheme {
+ return openFileResource(u)
+
+ } else if "http" == u.Scheme || "https" == u.Scheme {
+ return openHttpResource(resourceUrl)
+
+ } else {
+ return nil, errors.New("Unrecognised protocol scheme: " + u.Scheme)
+ }
+}
+
+func openFileResource(url *url.URL) (io.ReadCloser, error) {
+ filePath := url.Path;
+ file, err := os.Open(filepath.Clean(filePath))
+ if err != nil {
+ return nil, err
+ }
+ return file, nil
+}
+
+func openHttpResource(resourceUrl string) (io.ReadCloser, error) {
+ resp, err := http.Get(resourceUrl)
+ if err != nil {
+ return nil, err
+ }
+ return resp.Body, nil
+}
+
+
+func VerifyLoginURL(network *Network) error {
+ url, err := url.Parse(network.BrooklynUrl)
+ if err != nil {
+ return err
+ }
+ if url.Scheme != "http" && url.Scheme != "https" {
+ return errors.New("Use login command to set Brooklyn URL with a scheme of \"http\" or \"https\"")
+ }
+ if url.Host == "" {
+ return errors.New("Use login command to set Brooklyn URL with a valid host[:port]")
+ }
+ return nil
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/pom.xml
----------------------------------------------------------------------
diff --git a/cli/pom.xml b/cli/pom.xml
new file mode 100644
index 0000000..7cfb782
--- /dev/null
+++ b/cli/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-client</artifactId>
+ <version>0.10.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <packaging>pom</packaging>
+
+ <artifactId>brooklyn-client-cli</artifactId>
+ <name>Brooklyn Client Command Line Interface</name>
+ <description>
+ A command line client for Apache Brooklyn
+ </description>
+
+
+ <!--
+
+ Run as one of:
+
+ mvn -Dtarget=native clean install build for local platform
+ mvn -Dtarget=all clean install build for all supported platforms
+ mvn -Dtarget=cross -Dos=OS -Darch=ARCH clean install build for platform with operating system OS and architecture ARCH
+
+ -->
+
+ <properties>
+ <maven.antrun.plugin.version>1.8</maven.antrun.plugin.version>
+ <maven.assembly.plugin.version>2.6</maven.assembly.plugin.version>
+ <target>all</target>
+ </properties>
+
+ <repositories>
+ <!--
+ Same as in the parent apache pom. Repeated here in case
+ direct parent's pom not found at relativePath. Can't fetch
+ the parent from remote repos for snapshot versions - no
+ snapshot repos enabled by default.
+ -->
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <id>process-build-all</id>
+ <phase>compile</phase>
+ <configuration>
+ <target>
+ <ant target="${target}"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>${maven.assembly.plugin.version}</version>
+ <configuration>
+ <descriptors>
+ <descriptor>release/assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <version>0.11</version>
+ <configuration>
+ <excludes combine.children="append">
+ <exclude>vendor/**</exclude>
+ <exclude>glide.*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/release/assembly.xml
----------------------------------------------------------------------
diff --git a/cli/release/assembly.xml b/cli/release/assembly.xml
new file mode 100644
index 0000000..8a32f91
--- /dev/null
+++ b/cli/release/assembly.xml
@@ -0,0 +1,43 @@
+<!--
+ 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.
+-->
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
+ <id>bin</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>release/files</directory>
+ <outputDirectory><!-- leave blank, meaning 'root of archive' --></outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>release/license/files</directory>
+ <outputDirectory><!-- leave blank, meaning 'root of archive' --></outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}/bin</directory>
+ <outputDirectory><!-- leave blank, meaning 'root of archive' --></outputDirectory>
+ <includes>
+ <include>**/br*</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/release/build.bat
----------------------------------------------------------------------
diff --git a/cli/release/build.bat b/cli/release/build.bat
new file mode 100644
index 0000000..cbef33a
--- /dev/null
+++ b/cli/release/build.bat
@@ -0,0 +1,24 @@
+@echo off
+REM Licensed to the Apache Software Foundation (ASF) under one
+REM or more contributor license agreements. See the NOTICE file
+REM distributed with this work for additional information
+REM regarding copyright ownership. The ASF licenses this file
+REM to you under the Apache License, Version 2.0 (the
+REM "License"); you may not use this file except in compliance
+REM with the License. You may obtain a copy of the License at
+REM
+REM http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM Unless required by applicable law or agreed to in writing,
+REM software distributed under the License is distributed on an
+REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+REM KIND, either express or implied. See the License for the
+REM specific language governing permissions and limitations
+REM under the License.
+
+REM TODO
+echo.
+echo brooklyn-client CLI build not supported on Windows platforms, run maven with '-Dno-go-client' to skip.
+echo.
+
+exit 1
[03/10] brooklyn-client git commit: move rest-client to
brooklyn-client
Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/pom.xml
----------------------------------------------------------------------
diff --git a/java/pom.xml b/java/pom.xml
new file mode 100644
index 0000000..a305f4e
--- /dev/null
+++ b/java/pom.xml
@@ -0,0 +1,719 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>brooklyn-rest-client</artifactId>
+ <packaging>jar</packaging>
+ <name>Brooklyn REST java Client</name>
+ <description>
+ Client library for Brooklyn REST interface
+ </description>
+
+ <parent>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-client</artifactId>
+ <version>0.10.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-rest-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jackson2-provider</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-utils-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-core</artifactId>
+ <version>${project.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-rest-server</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-rest-resources</artifactId>
+ <version>${project.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-rest-server</artifactId>
+ <version>${project.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-test-support</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.mockwebserver</groupId>
+ <artifactId>mockwebserver</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>*,org.jboss.resteasy.client.core.marshallers</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>Documentation</id>
+ <reporting>
+ <excludeDefaults>true</excludeDefaults>
+ <plugins>
+ <plugin>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.4</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>index</report>
+ <report>modules</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.8</version>
+ <configuration>
+ <links>
+ <link>http://download.oracle.com/javaee/6/api</link>
+ </links>
+ <keywords>true</keywords>
+ <author>false</author>
+ <quiet>true</quiet>
+ <aggregate>false</aggregate>
+ <detectLinks />
+ <tags>
+ <tag>
+ <name>todo</name>
+ <placement>a</placement>
+ <head>To-do:</head>
+ </tag>
+ </tags>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <id>javadoc</id>
+ <reports>
+ <report>javadoc</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+ </profile>
+ <profile>
+ <id>Bundle</id>
+ <activation>
+ <file>
+ <!-- NB - this is all the leaf projects, including logback-* (with no src);
+ the archetype project neatly ignores this however -->
+ <exists>${basedir}/src</exists>
+ </file>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <!-- configure plugin to generate MANIFEST.MF
+ adapted from http://blog.knowhowlab.org/2010/06/osgi-tutorial-from-project-structure-to.html -->
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <supportedProjectTypes>
+ <supportedProjectType>jar</supportedProjectType>
+ </supportedProjectTypes>
+ <instructions>
+ <!-- OSGi specific instruction -->
+ <!--
+ By default packages containing impl and internal
+ are not included in the export list. Setting an
+ explicit wildcard will include all packages
+ regardless of name.
+ In time we should minimize our export lists to
+ what is really needed.
+ -->
+ <Export-Package>brooklyn.*,org.apache.brooklyn.*</Export-Package>
+ <Implementation-SHA-1>${buildNumber}</Implementation-SHA-1>
+ <Implementation-Branch>${scmBranch}</Implementation-Branch>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <archive>
+ <manifestFile> ${project.build.outputDirectory}/META-INF/MANIFEST.MF </manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>Tests</id>
+ <activation>
+ <file> <exists>${basedir}/src/test</exists> </file>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <configuration>
+ <properties>
+ <property>
+ <name>listener</name>
+ <value>org.apache.brooklyn.test.support.LoggingVerboseReporter,org.apache.brooklyn.test.support.BrooklynLeakListener,org.apache.brooklyn.test.support.PlatformTestSelectorListener</value>
+ </property>
+ </properties>
+ <enableAssertions>true</enableAssertions>
+ <groups>${includedTestGroups}</groups>
+ <excludedGroups>${excludedTestGroups}</excludedGroups>
+ <testFailureIgnore>false</testFailureIgnore>
+ <systemPropertyVariables>
+ <verbose>-1</verbose>
+ <net.sourceforge.cobertura.datafile>${project.build.directory}/cobertura/cobertura.ser</net.sourceforge.cobertura.datafile>
+ <cobertura.user.java.nio>false</cobertura.user.java.nio>
+ </systemPropertyVariables>
+ <printSummary>true</printSummary>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <id>test-jar-creation</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ <configuration>
+ <forceCreation>true</forceCreation>
+ <archive combine.self="override" />
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>Integration</id>
+ <properties>
+ <includedTestGroups>Integration</includedTestGroups>
+ <excludedTestGroups>Acceptance,Live,WIP,Broken</excludedTestGroups>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <id>run-tests</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>integration-test</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>Acceptance</id>
+ <properties>
+ <includedTestGroups>Acceptance</includedTestGroups>
+ <excludedTestGroups>Integration,Live,WIP,Broken</excludedTestGroups>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <id>run-tests</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>integration-test</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>Live</id>
+ <properties>
+ <includedTestGroups>Live</includedTestGroups>
+ <excludedTestGroups>Acceptance,WIP,Broken</excludedTestGroups>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>Live-sanity</id>
+ <properties>
+ <includedTestGroups>Live-sanity</includedTestGroups>
+ <excludedTestGroups>Acceptance,WIP,Broken</excludedTestGroups>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>CI</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <xmlOutput>true</xmlOutput>
+ <xmlOutputDirectory>target/site</xmlOutputDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>findbugs</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>2.5</version>
+ <inherited>true</inherited>
+ <configuration>
+ <failOnViolation>false</failOnViolation>
+ <linkXref>true</linkXref>
+ <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
+ <minimumTokens>100</minimumTokens>
+ <targetJdk>${java.version}</targetJdk>
+ <excludes>
+ <exclude>**/*Test.java</exclude>
+ <exclude>**/tests/**/*.java</exclude>
+ <!-- add any more generated source code directories here -->
+ </excludes>
+ <excludeRoots>
+ <excludeRoot>
+ ${pom.basedir}/target/generated-sources/groovy-stubs/main
+ </excludeRoot>
+ </excludeRoots>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>check</goal>
+ <goal>cpd-check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>Coverage</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>${cobertura.plugin.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <id>run-tests</id>
+ </execution>
+ <execution>
+ <id>instrument classes</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>process-test-classes</phase>
+ <configuration>
+ <target>
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath" />
+ <taskdef resource="tasks.properties" classpathref="maven.plugin.classpath" />
+ <if>
+ <available property="gogocobertura" file="target/test-classes" />
+ <then>
+ <echo message="INSTRUMENTING CLASSES FOR COBERTURA" />
+ <!-- Ensure any and all bits of our project are copied in first -->
+ <copy todir="target/cobertura/coverage-classes">
+ <fileset erroronmissingdir="false" dir="target/classes" />
+ </copy>
+ <cobertura-instrument datafile="target/cobertura/cobertura.ser" todir="target/test-classes">
+ <fileset erroronmissingdir="false" dir="target/classes">
+ <include name="brooklyn/**/*.class" />
+ <exclude name="brooklyn/**/*Test.class" />
+ </fileset>
+ <fileset erroronmissingdir="false" dir="target/cobertura/dependency-classes">
+ <include name="brooklyn/**/*.class" />
+ <exclude name="brooklyn/**/*Test.class" />
+ </fileset>
+ </cobertura-instrument>
+ </then>
+ </if>
+ </target>
+ </configuration>
+ </execution>
+ <execution>
+ <id>coverage report</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>post-integration-test</phase>
+ <configuration>
+ <target>
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath" />
+ <taskdef resource="tasks.properties" classpathref="maven.plugin.classpath" />
+ <if>
+ <available property="gogocobertura" file="target/cobertura/cobertura.ser" />
+ <then>
+ <echo message="GENERATING COBERTURA COVERAGE REPORT" />
+ <cobertura-report format="xml" destdir="target/site/cobertura" datafile="target/cobertura/cobertura.ser">
+ <fileset erroronmissingdir="false" dir="src/main/java" />
+ <fileset erroronmissingdir="false" dir="target/cobertura/dependency-sources" />
+ </cobertura-report>
+ <cobertura-report format="html" destdir="target/site/cobertura" datafile="target/cobertura/cobertura.ser">
+ <fileset erroronmissingdir="false" dir="src/main/java" />
+ <fileset erroronmissingdir="false" dir="target/cobertura/dependency-sources" />
+ </cobertura-report>
+ </then>
+ </if>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>ant-contrib</groupId>
+ <artifactId>ant-contrib</artifactId>
+ <version>1.0b3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>${ant.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>${ant.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>${testng.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>${cobertura.plugin.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack-coverage-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ <configuration>
+ <classifier>sources</classifier>
+ <includeScope>compile</includeScope>
+ <includeGroupIds>brooklyn</includeGroupIds>
+ <outputDirectory>
+ ${project.build.directory}/cobertura/dependency-sources
+ </outputDirectory>
+ <failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
+ </configuration>
+ </execution>
+ <execution>
+ <id>unpack-coverage-classes</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ <configuration>
+ <type>jar</type>
+ <includeScope>compile</includeScope>
+ <includeGroupIds>brooklyn</includeGroupIds>
+ <outputDirectory>
+ ${project.build.directory}/cobertura/dependency-classes
+ </outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <inherited>true</inherited>
+ <configuration>
+ <reportFormat>xml</reportFormat>
+ <classesDirectory>${project.build.directory}/cobertura/coverage-classes</classesDirectory>
+ <systemProperties>
+ <property>
+ <name>net.sourceforge.cobertura.datafile</name>
+ <value>${project.build.directory}/cobertura/cobertura.ser
+ </value>
+ </property>
+ <property>
+ <name>cobertura.user.java.nio</name>
+ <value>false</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>test-jar-creation</id>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- build sources jars by default, it's quick -->
+ <profile>
+ <id>make-sources-jar</id>
+ <activation> <property><name>!skipSources</name></property> </activation>
+ <build><plugins><plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin></plugins></build>
+ </profile>
+
+ <!-- only build javadoc if asked, or if deploying (it's slow) -->
+ <profile>
+ <id>make-javadoc-jar</id>
+ <activation> <property><name>javadoc</name></property> </activation>
+ <build><plugins><plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin></plugins></build>
+ </profile>
+
+ <!-- sign and make javadoc when deploying; note, this means you'll need gpg set up to deploy -->
+ <profile>
+ <id>make-more-things-when-deploying</id>
+ <activation> <property><name>brooklyn.deployTo</name></property> </activation>
+ <build><plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-gpg-plugin</artifactId>
+ </plugin>
+ </plugins></build>
+ </profile>
+ <profile>
+ <id>apache-repo</id>
+ <activation> <property><name>brooklyn.deployTo</name><value>apache</value></property> </activation>
+ <!-- distributionManagement configured by the parent Apache POM -->
+ </profile>
+ <profile>
+ <id>rat-check</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>rat-check</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>eclipse-compiler</id>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerId>eclipse</compilerId>
+ <optimize>true</optimize>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-eclipse</artifactId>
+ <version>2.6</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
----------------------------------------------------------------------
diff --git a/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java b/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
new file mode 100644
index 0000000..822e296
--- /dev/null
+++ b/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
@@ -0,0 +1,419 @@
+/*
+ * 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 org.apache.brooklyn.rest.client;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.annotation.Nullable;
+import javax.ws.rs.core.Response;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.jboss.resteasy.client.ClientExecutor;
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.client.ProxyBuilder;
+import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor;
+import org.jboss.resteasy.client.core.extractors.DefaultEntityExtractorFactory;
+import org.jboss.resteasy.specimpl.BuiltResponse;
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
+import org.jboss.resteasy.util.GenericType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+
+import org.apache.brooklyn.rest.api.AccessApi;
+import org.apache.brooklyn.rest.api.ActivityApi;
+import org.apache.brooklyn.rest.api.ApplicationApi;
+import org.apache.brooklyn.rest.api.CatalogApi;
+import org.apache.brooklyn.rest.api.EffectorApi;
+import org.apache.brooklyn.rest.api.EntityApi;
+import org.apache.brooklyn.rest.api.EntityConfigApi;
+import org.apache.brooklyn.rest.api.LocationApi;
+import org.apache.brooklyn.rest.api.PolicyApi;
+import org.apache.brooklyn.rest.api.PolicyConfigApi;
+import org.apache.brooklyn.rest.api.ScriptApi;
+import org.apache.brooklyn.rest.api.SensorApi;
+import org.apache.brooklyn.rest.api.ServerApi;
+import org.apache.brooklyn.rest.api.UsageApi;
+import org.apache.brooklyn.rest.api.VersionApi;
+import org.apache.brooklyn.rest.client.util.http.BuiltResponsePreservingError;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.javalang.AggregateClassLoader;
+import org.apache.brooklyn.util.net.Urls;
+
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * @author Adam Lowe
+ */
+@SuppressWarnings("deprecation")
+public class BrooklynApi {
+
+ private final String target;
+ private final ClientExecutor clientExecutor;
+ private final int maxPoolSize;
+ private final int timeOutInMillis;
+ private static final Logger LOG = LoggerFactory.getLogger(BrooklynApi.class);
+
+ /**
+ * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String)} instead
+ */
+ @Deprecated
+ public BrooklynApi(URL endpoint) {
+ this(checkNotNull(endpoint, "endpoint").toString());
+ }
+
+ /**
+ * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String)} instead
+ */
+ @Deprecated
+ public BrooklynApi(String endpoint) {
+ // username/password cannot be null, but credentials can
+ this(endpoint, null);
+ }
+
+ /**
+ * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String, String, String)} instead
+ */
+ @Deprecated
+ public BrooklynApi(URL endpoint, String username, String password) {
+ this(endpoint.toString(), new UsernamePasswordCredentials(username, password));
+ }
+
+ /**
+ * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String, String, String)} instead
+ */
+ @Deprecated
+ public BrooklynApi(String endpoint, String username, String password) {
+ this(endpoint, new UsernamePasswordCredentials(username, password));
+ }
+
+ /**
+ * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String, String, String)} instead
+ */
+ @Deprecated
+ public BrooklynApi(URL endpoint, @Nullable Credentials credentials) {
+ this(endpoint.toString(), credentials);
+ }
+
+ /**
+ * Creates a BrooklynApi using an HTTP connection pool
+ *
+ * @deprecated since 0.9.0. Use {@link BrooklynApi#newInstance(String, String, String)} instead
+ */
+ @Deprecated
+ public BrooklynApi(String endpoint, @Nullable Credentials credentials) {
+ this(endpoint, credentials, 20, 5000);
+ }
+
+ /**
+ * Creates a BrooklynApi using a custom ClientExecutor
+ *
+ * @param endpoint the Brooklyn endpoint
+ * @param clientExecutor the ClientExecutor
+ * @see #getClientExecutor(org.apache.http.auth.Credentials)
+ */
+ public BrooklynApi(URL endpoint, ClientExecutor clientExecutor) {
+ this.target = addV1SuffixIfNeeded(checkNotNull(endpoint, "endpoint").toString());
+ this.maxPoolSize = -1;
+ this.timeOutInMillis = -1;
+ this.clientExecutor = checkNotNull(clientExecutor, "clientExecutor");
+ }
+
+ /**
+ * Creates a BrooklynApi using an HTTP connection pool
+ *
+ * @param endpoint the Brooklyn endpoint
+ * @param credentials user credentials or null
+ * @param maxPoolSize maximum pool size
+ * @param timeOutInMillis connection timeout in milliseconds
+ */
+ public BrooklynApi(String endpoint, @Nullable Credentials credentials, int maxPoolSize, int timeOutInMillis) {
+ try {
+ new URL(checkNotNull(endpoint, "endpoint"));
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException(e);
+ }
+ this.target = addV1SuffixIfNeeded(endpoint);
+ this.maxPoolSize = maxPoolSize;
+ this.timeOutInMillis = timeOutInMillis;
+ this.clientExecutor = getClientExecutor(credentials);
+ }
+
+ private String addV1SuffixIfNeeded(String endpoint) {
+ if (!endpoint.endsWith("/v1/") && !endpoint.endsWith("/v1")) {
+ return Urls.mergePaths(endpoint, "v1");
+ } else {
+ return endpoint;
+ }
+ }
+
+ private Supplier<PoolingHttpClientConnectionManager> connectionManagerSupplier = Suppliers.memoize(new Supplier<PoolingHttpClientConnectionManager>() {
+ @Override
+ public PoolingHttpClientConnectionManager get() {
+ PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
+ connManager.setMaxTotal(maxPoolSize);
+ connManager.setDefaultMaxPerRoute(maxPoolSize);
+ return connManager;
+ }
+ });
+
+ private Supplier<RequestConfig> reqConfSupplier = Suppliers.memoize(new Supplier<RequestConfig>() {
+ @Override
+ public RequestConfig get() {
+ return RequestConfig.custom()
+ .setConnectTimeout(timeOutInMillis)
+ .setConnectionRequestTimeout(timeOutInMillis)
+ .build();
+ }
+ });
+
+ /**
+ * Creates a ClientExecutor for this BrooklynApi
+ */
+ protected ClientExecutor getClientExecutor(Credentials credentials) {
+ CredentialsProvider provider = new BasicCredentialsProvider();
+ if (credentials != null) provider.setCredentials(AuthScope.ANY, credentials);
+
+ CloseableHttpClient httpClient = HttpClients.custom()
+ .setDefaultCredentialsProvider(provider)
+ .setDefaultRequestConfig(reqConfSupplier.get())
+ .setConnectionManager(connectionManagerSupplier.get())
+ .build();
+
+ return new ApacheHttpClient4Executor(httpClient);
+ }
+
+ /**
+ * Creates a BrooklynApi using an HTTP connection pool
+ *
+ * @param endpoint the Brooklyn endpoint
+ * @return a new BrooklynApi instance
+ */
+ public static BrooklynApi newInstance(String endpoint) {
+ return new BrooklynApi(endpoint, null);
+ }
+
+ /**
+ * Creates a BrooklynApi using an HTTP connection pool
+ *
+ * @param endpoint the Brooklyn endpoint
+ * @param maxPoolSize maximum connection pool size
+ * @param timeOutInMillis connection timeout in millisecond
+ * @return a new BrooklynApi instance
+ */
+ public static BrooklynApi newInstance(String endpoint, int maxPoolSize, int timeOutInMillis) {
+ return new BrooklynApi(endpoint, null, maxPoolSize, timeOutInMillis);
+ }
+
+ /**
+ * Creates a BrooklynApi using an HTTP connection pool
+ *
+ * @param endpoint the Brooklyn endpoint
+ * @param username for authentication
+ * @param password for authentication
+ * @return a new BrooklynApi instance
+ */
+ public static BrooklynApi newInstance(String endpoint, String username, String password) {
+ return new BrooklynApi(endpoint, new UsernamePasswordCredentials(username, password));
+ }
+
+ /**
+ * Creates a BrooklynApi using an HTTP connection pool
+ *
+ * @param endpoint the Brooklyn endpoint
+ * @param username for authentication
+ * @param password for authentication
+ * @param maxPoolSize maximum connection pool size
+ * @param timeOutInMillis connection timeout in millisecond
+ * @return a new BrooklynApi instance
+ */
+ public static BrooklynApi newInstance(String endpoint, String username, String password, int maxPoolSize, int timeOutInMillis) {
+ return new BrooklynApi(endpoint, new UsernamePasswordCredentials(username, password), maxPoolSize, timeOutInMillis);
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> T proxy(Class<T> clazz) {
+ AggregateClassLoader aggregateClassLoader = AggregateClassLoader.newInstanceWithNoLoaders();
+ aggregateClassLoader.addLast(clazz.getClassLoader());
+ aggregateClassLoader.addLast(getClass().getClassLoader());
+
+ final T result0 = ProxyBuilder.build(clazz, target)
+ .executor(clientExecutor)
+ .classloader(aggregateClassLoader)
+ .providerFactory(ResteasyProviderFactory.getInstance())
+ .extractorFactory(new DefaultEntityExtractorFactory())
+ .requestAttributes(MutableMap.<String, Object>of())
+ .now();
+
+ return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] { clazz }, new InvocationHandler() {
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ try {
+ Object result1 = method.invoke(result0, args);
+ Class<?> type = String.class;
+ if (result1 instanceof Response) {
+ Response resp = (Response)result1;
+ if(isStatusCodeHealthy(resp.getStatus()) && method.isAnnotationPresent(ApiOperation.class)) {
+ type = getClassFromMethodAnnotationOrDefault(method, type);
+ }
+ // wrap the original response so it self-closes
+ result1 = BuiltResponsePreservingError.copyResponseAndClose(resp, type);
+ }
+ return result1;
+ } catch (Throwable e) {
+ if (e instanceof InvocationTargetException) {
+ // throw the original exception
+ e = ((InvocationTargetException)e).getTargetException();
+ }
+ throw Exceptions.propagate(e);
+ }
+ }
+
+ private boolean isStatusCodeHealthy(int code) { return (code>=200 && code<=299); }
+
+ private Class<?> getClassFromMethodAnnotationOrDefault(Method method, Class<?> def){
+ Class<?> type;
+ try{
+ type = method.getAnnotation(ApiOperation.class).response();
+ } catch (Exception e) {
+ type = def;
+ LOG.debug("Unable to get class from annotation: {}. Defaulting to {}", e.getMessage(), def.getName());
+ Exceptions.propagateIfFatal(e);
+ }
+ return type;
+ }
+ });
+ }
+
+ public ActivityApi getActivityApi() {
+ return proxy(ActivityApi.class);
+ }
+
+ public ApplicationApi getApplicationApi() {
+ return proxy(ApplicationApi.class);
+ }
+
+ public CatalogApi getCatalogApi() {
+ return proxy(CatalogApi.class);
+ }
+
+ public EffectorApi getEffectorApi() {
+ return proxy(EffectorApi.class);
+ }
+
+ public EntityConfigApi getEntityConfigApi() {
+ return proxy(EntityConfigApi.class);
+ }
+
+ public EntityApi getEntityApi() {
+ return proxy(EntityApi.class);
+ }
+
+ public LocationApi getLocationApi() {
+ return proxy(LocationApi.class);
+ }
+
+ public PolicyConfigApi getPolicyConfigApi() {
+ return proxy(PolicyConfigApi.class);
+ }
+
+ public PolicyApi getPolicyApi() {
+ return proxy(PolicyApi.class);
+ }
+
+ public ScriptApi getScriptApi() {
+ return proxy(ScriptApi.class);
+ }
+
+ public SensorApi getSensorApi() {
+ return proxy(SensorApi.class);
+ }
+
+ public ServerApi getServerApi() {
+ return proxy(ServerApi.class);
+ }
+
+ public UsageApi getUsageApi() {
+ return proxy(UsageApi.class);
+ }
+
+ public VersionApi getVersionApi() {
+ return proxy(VersionApi.class);
+ }
+
+ public AccessApi getAccessApi() {
+ return proxy(AccessApi.class);
+ }
+
+ public static <T> T getEntity(Response response, Class<T> type) {
+ if (response instanceof ClientResponse) {
+ ClientResponse<?> clientResponse = (ClientResponse<?>) response;
+ return clientResponse.getEntity(type);
+ } else if (response instanceof BuiltResponse) {
+ // Handle BuiltResponsePreservingError turning objects into Strings
+ if (response.getEntity() instanceof String && !type.equals(String.class)) {
+ return new Gson().fromJson(response.getEntity().toString(), type);
+ }
+ }
+ // Last-gasp attempt.
+ return type.cast(response.getEntity());
+ }
+
+ public static <T> T getEntity(Response response, GenericType<T> type) {
+ if (response instanceof ClientResponse) {
+ ClientResponse<?> clientResponse = (ClientResponse<?>) response;
+ return clientResponse.getEntity(type);
+ } else if (response instanceof BuiltResponse) {
+ // Handle BuiltResponsePreservingError turning objects into Strings
+ if (response.getEntity() instanceof String) {
+ return new Gson().fromJson(response.getEntity().toString(), type.getGenericType());
+ }
+ }
+ // Last-gasp attempt.
+ return type.getType().cast(response.getEntity());
+ }
+
+ /**
+ * @deprecated since 0.8.0-incubating. Use {@link #getEntity(Response, GenericType)} instead.
+ */
+ @Deprecated
+ public static <T> T getEntityGeneric(Response response, GenericType<T> type) {
+ return getEntity(response, type);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java
----------------------------------------------------------------------
diff --git a/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java b/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java
new file mode 100644
index 0000000..ce57da5
--- /dev/null
+++ b/java/src/main/java/org/apache/brooklyn/rest/client/BrooklynApiUtil.java
@@ -0,0 +1,154 @@
+/*
+ * 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 org.apache.brooklyn.rest.client;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Date;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.rest.api.EffectorApi;
+import org.apache.brooklyn.rest.domain.Status;
+import org.apache.brooklyn.rest.domain.TaskSummary;
+import org.apache.brooklyn.util.repeat.Repeater;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableMap;
+
+public class BrooklynApiUtil {
+
+ private static final Logger LOG = LoggerFactory.getLogger(BrooklynApiUtil.class);
+ private static final Duration DEFAULT_POLL_PERIOD = Duration.FIVE_SECONDS;
+ private static final Duration DEFAULT_TIMEOUT = Duration.FIVE_MINUTES;
+
+ private BrooklynApiUtil() {}
+
+ /**
+ * Deploys the blueprint and returns the task summary.
+ * @throws Exception If the response from the server when deploying was {@link #isUnhealthyResponse unhealthy}.
+ */
+ public static TaskSummary deployBlueprint(BrooklynApi api, String blueprint) throws Exception {
+ Response r = api.getApplicationApi().createFromYaml(blueprint);
+ if (isUnhealthyResponse(r)) {
+ throw new Exception("Unexpected response deploying blueprint to server: " + r.getStatus());
+ } else {
+ LOG.debug("Server response to deploy blueprint: " + r.getStatus());
+ }
+ return BrooklynApi.getEntity(r, TaskSummary.class);
+ }
+
+ /**
+ * Waits for the application with the given ID to be running.
+ *
+ * @throws IllegalStateException If the application was not running after {@link #DEFAULT_TIMEOUT}.
+ */
+ public static void waitForRunningAndThrowOtherwise(BrooklynApi api, String applicationId, String taskId) throws IllegalStateException {
+ waitForRunningAndThrowOtherwise(api, applicationId, taskId, DEFAULT_TIMEOUT);
+ }
+
+ /**
+ * Waits for the application with the given ID to be running.
+ *
+ * @throws IllegalStateException If the application was not running after the given timeout.
+ */
+ public static void waitForRunningAndThrowOtherwise(BrooklynApi api, String applicationId, String taskId, Duration timeout) throws IllegalStateException {
+ Status finalStatus = waitForAppStatus(api, applicationId, Status.RUNNING, timeout, DEFAULT_POLL_PERIOD);
+ if (!Status.RUNNING.equals(finalStatus)) {
+ LOG.error("Application is not running. Is: " + finalStatus.name().toLowerCase());
+
+ StringBuilder message = new StringBuilder();
+ message.append("Application ").append(applicationId)
+ .append(" should be running but is ").append(finalStatus.name().toLowerCase())
+ .append(". ");
+
+ if (Status.ERROR.equals(finalStatus) || Status.UNKNOWN.equals(finalStatus)) {
+ String result = getTaskResult(api, taskId);
+ message.append("\nThe result of the task on the server was:\n")
+ .append(result);
+ }
+ throw new IllegalStateException(message.toString());
+ }
+ }
+
+ /**
+ * Polls Brooklyn until the given application has the given status. Quits early if the
+ * application's status is {@link org.apache.brooklyn.rest.domain.Status#ERROR} or
+ * {@link org.apache.brooklyn.rest.domain.Status#UNKNOWN} and desiredStatus is something else.
+ *
+ * @return The final polled status.
+ */
+ public static Status waitForAppStatus(final BrooklynApi api, final String application, final Status desiredStatus,
+ Duration timeout, Duration pollPeriod) {
+ final AtomicReference<Status> appStatus = new AtomicReference<>(Status.UNKNOWN);
+ final boolean shortcutOnError = !Status.ERROR.equals(desiredStatus) && !Status.UNKNOWN.equals(desiredStatus);
+ LOG.info("Waiting " + timeout + " from " + new Date() + " for application " + application + " to be " + desiredStatus);
+ boolean finalAppStatusKnown = Repeater.create("Waiting for application " + application + " status to be " + desiredStatus)
+ .every(pollPeriod)
+ .limitTimeTo(timeout)
+ .rethrowExceptionImmediately()
+ .until(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ Status status = api.getApplicationApi().get(application).getStatus();
+ LOG.debug("Application " + application + " status is: " + status);
+ appStatus.set(status);
+ return desiredStatus.equals(status) || (shortcutOnError &&
+ (Status.ERROR.equals(status) || Status.UNKNOWN.equals(status)));
+ }
+ })
+ .run();
+ if (appStatus.get().equals(desiredStatus)) {
+ LOG.info("Application " + application + " is " + desiredStatus.name());
+ } else {
+ LOG.warn("Application is not " + desiredStatus.name() + " within " + timeout +
+ ". Status is: " + appStatus.get());
+ }
+ return appStatus.get();
+ }
+
+ /**
+ * Use the {@link EffectorApi effector API} to invoke the stop effector on the given application.
+ */
+ public static void attemptStop(BrooklynApi api, String application, Duration timeout) {
+ api.getEffectorApi().invoke(application, application, "stop", String.valueOf(timeout.toMilliseconds()),
+ ImmutableMap.<String, Object>of());
+ }
+
+ /**
+ * @return The result of the task with the given id, or "unknown" if it could not be found.
+ */
+ public static String getTaskResult(BrooklynApi api, String taskId) {
+ checkNotNull(taskId, "taskId");
+ TaskSummary summary = api.getActivityApi().get(taskId);
+ return summary == null || summary.getResult() == null ? "unknown" : summary.getResult().toString();
+ }
+
+ /**
+ * @return true if response's status code is not between 200 and 299 inclusive.
+ */
+ public static boolean isUnhealthyResponse(Response response) {
+ return response.getStatus() < 200 || response.getStatus() >= 300;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java
----------------------------------------------------------------------
diff --git a/java/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java b/java/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java
new file mode 100644
index 0000000..d011172
--- /dev/null
+++ b/java/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java
@@ -0,0 +1,79 @@
+/*
+ * 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 org.apache.brooklyn.rest.client.util.http;
+
+import java.lang.annotation.Annotation;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.jboss.resteasy.client.core.BaseClientResponse;
+import org.jboss.resteasy.core.Headers;
+import org.jboss.resteasy.specimpl.BuiltResponse;
+
+/**
+ * Allows wrapping a {@link Response} with the stream fully read and closed so that the client can be re-used.
+ * <p>
+ * The entity may be stored as a string as type info is not available when it is deserialized,
+ * and that's a relatively convenient common format.
+ *
+ * TODO It would be nice to support other parsing, storing the byte array.
+ */
+public class BuiltResponsePreservingError extends BuiltResponse {
+
+ private Throwable error;
+
+ public BuiltResponsePreservingError(int status, Headers<Object> headers, Object entity, Annotation[] annotations, Throwable error) {
+ super(status, headers, entity, annotations);
+ this.error = error;
+ }
+
+ @SuppressWarnings("deprecation")
+ public static <T> Response copyResponseAndClose(Response source, Class<T> type) {
+ int status = -1;
+ Headers<Object> headers = new Headers<Object>();
+ Object entity = null;
+ try {
+ status = source.getStatus();
+ if (source instanceof BaseClientResponse)
+ headers.putAll(((BaseClientResponse<?>)source).getMetadata());
+ if (source instanceof org.jboss.resteasy.client.ClientResponse) {
+ entity = ((org.jboss.resteasy.client.ClientResponse<?>)source).getEntity(type);
+ } else {
+ entity = source.getEntity();
+ }
+ return new BuiltResponsePreservingError(status, headers, entity, new Annotation[0], null);
+ } catch (Exception e) {
+ Exceptions.propagateIfFatal(e);
+ return new BuiltResponsePreservingError(status, headers, entity, new Annotation[0], e);
+ } finally {
+ if (source instanceof BaseClientResponse)
+ ((BaseClientResponse<?>)source).close();
+ }
+ }
+
+ @Override
+ public Object getEntity() {
+ if (error!=null) {
+ throw new IllegalStateException("getEntity called on BuiltResponsePreservingError, where an Error had been preserved", error);
+ }
+ return super.getEntity();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/java/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java b/java/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java
new file mode 100644
index 0000000..81d789f
--- /dev/null
+++ b/java/src/test/java/org/apache/brooklyn/rest/client/ApplicationResourceIntegrationTest.java
@@ -0,0 +1,190 @@
+/*
+ * 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 org.apache.brooklyn.rest.client;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.util.Collection;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.api.entity.Application;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.entity.StartableApplication;
+import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.core.location.BasicLocationRegistry;
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.rest.BrooklynRestApiLauncher;
+import org.apache.brooklyn.rest.BrooklynRestApiLauncherTest;
+import org.apache.brooklyn.rest.domain.ApplicationSpec;
+import org.apache.brooklyn.rest.domain.ApplicationSummary;
+import org.apache.brooklyn.rest.domain.EntitySpec;
+import org.apache.brooklyn.rest.domain.EntitySummary;
+import org.apache.brooklyn.rest.domain.SensorSummary;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.time.Duration;
+import org.eclipse.jetty.server.Server;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import org.eclipse.jetty.server.NetworkConnector;
+
+@Test(singleThreaded = true)
+public class ApplicationResourceIntegrationTest {
+
+ private static final Logger log = LoggerFactory.getLogger(ApplicationResourceIntegrationTest.class);
+
+ private static final Duration LONG_WAIT = Duration.minutes(10);
+
+ private final String redisSpec = "{\"name\": \"redis-app\", \"type\": \"org.apache.brooklyn.entity.nosql.redis.RedisStore\", \"locations\": [ \"localhost\"]}";
+
+ private final ApplicationSpec legacyRedisSpec = ApplicationSpec.builder().name("redis-legacy-app")
+ .entities(ImmutableSet.of(new EntitySpec("redis-ent", "org.apache.brooklyn.entity.nosql.redis.RedisStore")))
+ .locations(ImmutableSet.of("localhost"))
+ .build();
+
+ private ManagementContext manager;
+
+ protected synchronized ManagementContext getManagementContext() throws Exception {
+ if (manager == null) {
+ manager = new LocalManagementContext();
+ BrooklynRestApiLauncherTest.forceUseOfDefaultCatalogWithJavaClassPath(manager);
+ BasicLocationRegistry.addNamedLocationLocalhost(manager);
+ BrooklynRestApiLauncherTest.enableAnyoneLogin(manager);
+ }
+ return manager;
+ }
+
+ BrooklynApi api;
+
+ @BeforeClass(groups = "Integration")
+ public void setUp() throws Exception {
+ Server server = BrooklynRestApiLauncher.launcher()
+ .managementContext(getManagementContext())
+ .start();
+
+ api = BrooklynApi.newInstance("http://localhost:" + ((NetworkConnector)server.getConnectors()[0]).getPort() + "/");
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void tearDown() throws Exception {
+ for (Application app : getManagementContext().getApplications()) {
+ try {
+ ((StartableApplication) app).stop();
+ } catch (Exception e) {
+ log.warn("Error stopping app " + app + " during test teardown: " + e);
+ }
+ }
+ }
+
+ @Test(groups = "Integration")
+ public void testDeployRedisApplication() throws Exception {
+ Response response = api.getApplicationApi().createPoly(redisSpec.getBytes());
+ assertEquals(response.getStatus(), 201);
+ assertEquals(getManagementContext().getApplications().size(), 1);
+ final String entityId = getManagementContext().getApplications().iterator().next().getChildren().iterator().next().getId();
+ assertServiceStateEventually("redis-app", entityId, Lifecycle.RUNNING, LONG_WAIT);
+ }
+
+ @Test(groups = "Integration", dependsOnMethods = "testDeployRedisApplication")
+ public void testDeployLegacyRedisApplication() throws Exception {
+ @SuppressWarnings("deprecation")
+ Response response = api.getApplicationApi().create(legacyRedisSpec);
+ assertEquals(response.getStatus(), 201);
+ assertEquals(getManagementContext().getApplications().size(), 2);
+ assertServiceStateEventually("redis-legacy-app", "redis-ent", Lifecycle.RUNNING, LONG_WAIT);
+
+ // Tear the app down so it doesn't interfere with other tests
+ Response deleteResponse = api.getApplicationApi().delete("redis-legacy-app");
+ assertEquals(deleteResponse.getStatus(), 202);
+ assertEquals(getManagementContext().getApplications().size(), 1);
+ }
+
+ @Test(groups = "Integration", dependsOnMethods = "testDeployRedisApplication")
+ public void testListEntities() {
+ Collection<EntitySummary> entities = api.getEntityApi().list("redis-app");
+ Assert.assertFalse(entities.isEmpty());
+ }
+
+ @Test(groups = "Integration", dependsOnMethods = "testDeployRedisApplication")
+ public void testListSensorsRedis() throws Exception {
+ String entityId = getManagementContext().getApplications().iterator().next().getChildren().iterator().next().getId();
+ Collection<SensorSummary> sensors = api.getSensorApi().list("redis-app", entityId);
+ assertTrue(sensors.size() > 0);
+ SensorSummary uptime = Iterables.find(sensors, new Predicate<SensorSummary>() {
+ @Override
+ public boolean apply(SensorSummary sensorSummary) {
+ return sensorSummary.getName().equals("redis.uptime");
+ }
+ });
+ assertEquals(uptime.getType(), "java.lang.Integer");
+ }
+
+ @Test(groups = "Integration", dependsOnMethods = {"testListSensorsRedis", "testListEntities"})
+ public void testTriggerRedisStopEffector() throws Exception {
+ final String entityId = getManagementContext().getApplications().iterator().next().getChildren().iterator().next().getId();
+ Response response = api.getEffectorApi().invoke("redis-app", entityId, "stop", "5000", ImmutableMap.<String, Object>of());
+
+ assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());
+ assertServiceStateEventually("redis-app", entityId, Lifecycle.STOPPED, LONG_WAIT);
+ }
+
+ @Test(groups = "Integration", dependsOnMethods = "testTriggerRedisStopEffector")
+ public void testDeleteRedisApplication() throws Exception {
+ int size = getManagementContext().getApplications().size();
+ Response response = api.getApplicationApi().delete("redis-app");
+ Assert.assertNotNull(response);
+ try {
+ Asserts.succeedsEventually(ImmutableMap.of("timeout", Duration.minutes(1)), new Runnable() {
+ public void run() {
+ try {
+ ApplicationSummary summary = api.getApplicationApi().get("redis-app");
+ fail("Redis app failed to disappear: summary="+summary);
+ } catch (Exception failure) {
+ // expected -- it will be a ClientResponseFailure but that class is deprecated so catching all
+ // and asserting contains the word 404
+ Assert.assertTrue(failure.toString().indexOf("404") >= 0, "wrong failure, got: "+failure);
+ }
+ }});
+ } catch (Exception failure) {
+ // expected -- as above
+ Assert.assertTrue(failure.toString().indexOf("404") >= 0, "wrong failure, got: "+failure);
+ }
+
+ assertEquals(getManagementContext().getApplications().size(), size - 1);
+ }
+
+ private void assertServiceStateEventually(final String app, final String entity, final Lifecycle state, Duration timeout) {
+ Asserts.succeedsEventually(ImmutableMap.of("timeout", timeout), new Runnable() {
+ public void run() {
+ Object status = api.getSensorApi().get(app, entity, "service.state", false);
+ assertTrue(state.toString().equalsIgnoreCase(status.toString()), "status="+status);
+ }});
+ }
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
----------------------------------------------------------------------
diff --git a/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java b/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
new file mode 100644
index 0000000..96c898e
--- /dev/null
+++ b/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
@@ -0,0 +1,163 @@
+/*
+ * 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 org.apache.brooklyn.rest.client;
+
+import static org.testng.Assert.assertEquals;
+
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.api.entity.Application;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.BrooklynVersion;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.StartableApplication;
+import org.apache.brooklyn.core.location.BasicLocationRegistry;
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.rest.BrooklynRestApiLauncher;
+import org.apache.brooklyn.rest.BrooklynRestApiLauncherTest;
+import org.apache.brooklyn.rest.domain.ApplicationSummary;
+import org.apache.brooklyn.rest.domain.CatalogLocationSummary;
+import org.apache.brooklyn.rest.security.provider.TestSecurityProvider;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.http.HttpAsserts;
+import org.eclipse.jetty.server.NetworkConnector;
+import org.eclipse.jetty.server.Server;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+@Test
+public class BrooklynApiRestClientTest {
+
+ private static final Logger log = LoggerFactory.getLogger(BrooklynApiRestClientTest.class);
+
+ private ManagementContext manager;
+ private Server server;
+ private BrooklynApi api;
+
+ protected synchronized ManagementContext getManagementContext() throws Exception {
+ if (manager == null) {
+ manager = new LocalManagementContext();
+ BrooklynRestApiLauncherTest.forceUseOfDefaultCatalogWithJavaClassPath(manager);
+ BasicLocationRegistry.addNamedLocationLocalhost(manager);
+ BrooklynRestApiLauncherTest.enableAnyoneLogin(manager);
+ }
+ return manager;
+ }
+
+ @BeforeClass
+ public void setUp() throws Exception {
+ server = BrooklynRestApiLauncher.launcher()
+ .managementContext(manager)
+ .securityProvider(TestSecurityProvider.class)
+ .start();
+
+ api = BrooklynApi.newInstance("http://localhost:" + ((NetworkConnector)server.getConnectors()[0]).getPort() + "/v1",
+ TestSecurityProvider.USER, TestSecurityProvider.PASSWORD);
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void tearDown() throws Exception {
+ for (Application app : getManagementContext().getApplications()) {
+ try {
+ ((StartableApplication) app).stop();
+ } catch (Exception e) {
+ log.warn("Error stopping app " + app + " during test teardown: " + e);
+ }
+ }
+ Entities.destroyAll(getManagementContext());
+ server.stop();
+ }
+
+ public void testNoV1InUrl() {
+ api = BrooklynApi.newInstance("http://localhost:" + ((NetworkConnector)server.getConnectors()[0]).getPort(),
+ TestSecurityProvider.USER, TestSecurityProvider.PASSWORD);
+
+ assertEquals(api.getServerApi().getVersion().getVersion(), BrooklynVersion.get());
+ }
+
+ public void testLocationApi() throws Exception {
+ log.info("Testing location API");
+ Map<String, Map<String, Object>> locations = api.getLocationApi().getLocatedLocations();
+ log.info("locations located are: "+locations);
+ }
+
+ public void testCatalogApiLocations() throws Exception {
+ List<CatalogLocationSummary> locations = api.getCatalogApi().listLocations(".*", null, false);
+ log.info("locations from catalog are: "+locations);
+ }
+
+ public void testCatalogCreate()throws Exception {
+ final Response response = api.getCatalogApi().create(getFileContentsAsString("catalog/test-catalog.bom"));
+ Asserts.assertEquals(response.getStatus(), 201);
+ Asserts.assertStringContains(String.valueOf(response.getEntity()), "simple-tomcat:1.0");
+ }
+
+
+
+ public void testApplicationApiList() throws Exception {
+ List<ApplicationSummary> apps = api.getApplicationApi().list(null);
+ log.info("apps are: "+apps);
+ }
+
+ public void testApplicationApiCreate() throws Exception {
+ Response r1 = api.getApplicationApi().createFromYaml("name: test-1234\n"
+ + "services: [ { type: "+TestEntity.class.getName()+" } ]");
+ HttpAsserts.assertHealthyStatusCode(r1.getStatus());
+ log.info("creation result: "+r1.getEntity());
+ List<ApplicationSummary> apps = api.getApplicationApi().list(null);
+ log.info("apps with test: "+apps);
+ Asserts.assertStringContains(apps.toString(), "test-1234");
+ }
+
+ public void testApplicationApiHandledError() throws Exception {
+ Response r1 = api.getApplicationApi().createFromYaml("name: test");
+ HttpAsserts.assertNotHealthyStatusCode(r1.getStatus());
+ // new-style messages first, old-style messages after (during switch to TypePlanTransformer)
+ Asserts.assertStringContainsAtLeastOne(r1.getEntity().toString().toLowerCase(),
+ "invalid plan", "no services");
+ Asserts.assertStringContainsAtLeastOne(r1.getEntity().toString().toLowerCase(),
+ "format could not be recognized", "Unrecognized application blueprint format");
+ }
+
+ public void testApplicationApiThrownError() throws Exception {
+ try {
+ ApplicationSummary summary = api.getApplicationApi().get("test-5678");
+ Asserts.shouldHaveFailedPreviously("got "+summary);
+ } catch (Exception e) {
+ Asserts.expectedFailureContainsIgnoreCase(e, "404", "not found");
+ }
+ }
+
+ private String getFileContentsAsString(final String filename) throws Exception {
+ final URL resource = getClass().getClassLoader().getResource(filename);
+ Asserts.assertNotNull(resource);
+ return new String(Files.readAllBytes(Paths.get(resource.toURI())), Charset.defaultCharset());
+ }
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java
----------------------------------------------------------------------
diff --git a/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java b/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java
new file mode 100644
index 0000000..9cae021
--- /dev/null
+++ b/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java
@@ -0,0 +1,129 @@
+/*
+ * 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 org.apache.brooklyn.rest.client;
+
+import static org.apache.brooklyn.test.Asserts.assertEquals;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.brooklyn.util.collections.Jsonya;
+import org.apache.brooklyn.util.core.http.BetterMockWebServer;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Joiner;
+import com.google.mockwebserver.MockResponse;
+import com.google.mockwebserver.RecordedRequest;
+
+public class BrooklynApiUtilTest {
+
+ private static final String APP_ID = "fedcba";
+
+ private static final String YAML = Joiner.on("\n").join(
+ "name: test-blueprint",
+ "location: localhost",
+ "services:",
+ "- type: brooklyn.entity.basic.EmptySoftwareProcess");
+
+ private BetterMockWebServer server;
+
+ @BeforeMethod(alwaysRun = true)
+ public void newMockWebServer() {
+ server = BetterMockWebServer.newInstanceLocalhost();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void shutDownServer() throws Exception {
+ if (server != null) server.shutdown();
+ }
+
+ @Test
+ public void testDeployBlueprint() throws Exception {
+ server.enqueue(taskSummaryResponse());
+ server.play();
+
+ BrooklynApi api = BrooklynApi.newInstance(server.getUrl("/").toString());
+ BrooklynApiUtil.deployBlueprint(api, YAML);
+
+ RecordedRequest request = server.takeRequest();
+ assertEquals(request.getPath(), "/v1/applications");
+ assertEquals(request.getMethod(), "POST");
+ assertEquals(new String(request.getBody()), YAML);
+ }
+
+ @Test
+ public void testWaitForRunningExitsCleanlyWhenAppRunning() throws Exception {
+ server.enqueue(applicationStatusResponse("RUNNING"));
+ server.play();
+
+ BrooklynApi api = BrooklynApi.newInstance(server.getUrl("/").toString());
+ BrooklynApiUtil.waitForRunningAndThrowOtherwise(api, "appId", "taskId");
+ // i.e. no exception
+ }
+
+ @Test(expectedExceptions = {IllegalStateException.class})
+ public void testWaitForRunningFailsWhenAppStatusError() throws Exception {
+ server.enqueue(applicationStatusResponse("ERROR"));
+ // Method checks for status of task.
+ server.enqueue(taskSummaryResponse());
+ server.play();
+
+ BrooklynApi api = BrooklynApi.newInstance(server.getUrl("/").toString());
+ BrooklynApiUtil.waitForRunningAndThrowOtherwise(api, "appId", "taskId");
+ }
+
+ @Test(expectedExceptions = {IllegalStateException.class})
+ public void testWaitForRunningFailsWhenAppStatusUnknown() throws Exception {
+ server.enqueue(applicationStatusResponse("UNKNOWN"));
+ // Method checks for status of task.
+ server.enqueue(taskSummaryResponse());
+ server.play();
+
+ BrooklynApi api = BrooklynApi.newInstance(server.getUrl("/").toString());
+ BrooklynApiUtil.waitForRunningAndThrowOtherwise(api, "appId", "taskId");
+ }
+
+ /** @return a response whose Content-Type header is application/json. */
+ private MockResponse newJsonResponse() {
+ return new MockResponse()
+ .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ }
+
+ private MockResponse taskSummaryResponse() {
+ String body = Jsonya.newInstance()
+ .put("id", "taskid")
+ .put("entityId", APP_ID)
+ .toString();
+ return newJsonResponse().setBody(body);
+ }
+
+ private MockResponse applicationStatusResponse(String status) {
+ String body = Jsonya.newInstance()
+ .put("status", status)
+ .at("spec", "locations").list().add("localhost")
+ .root()
+ .toString();
+ return newJsonResponse()
+ .setBody(body);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/java/src/test/resources/catalog/test-catalog.bom
----------------------------------------------------------------------
diff --git a/java/src/test/resources/catalog/test-catalog.bom b/java/src/test/resources/catalog/test-catalog.bom
new file mode 100644
index 0000000..698bcf2
--- /dev/null
+++ b/java/src/test/resources/catalog/test-catalog.bom
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+brooklyn.catalog:
+ id: simple-tomcat
+ version: 1.0
+ itemType: template
+ iconUrl: http://tomcat.apache.org/images/tomcat.png
+ name: Simple Tomcat
+ license: Apache-2.0
+ item:
+ brooklyn.config:
+ simple.confg: someValue
+ services:
+ - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+ id: tomcat
+ name: Tomcat
+ war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
\ No newline at end of file