nex_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4ae6ccb86acd03a0fbf4e551551c6ebbe38ebea
4
+ data.tar.gz: 6eba8f471e9caefbf1d31907ffe084dcc69ebd4e
5
+ SHA512:
6
+ metadata.gz: 4cc2d45e22cb810575f8aea00d767839ce67a605f1692692a943e12614cd8287495f5e5d9c25377d70db0455fb3373336df0fecfe5937fade08a76f82940d70e
7
+ data.tar.gz: 80dbd8e444186e1ddb630e3e0a2fbf602c491baf6cfe1e43b3c7a858059d4e2bd09b498055c8adc87f7b29a18673dc37ff887f4a2c3ac53fa6170fc59ffe00a7
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ <p align="center">
2
+ <img src="https://raw.github.com/maestrano/maestrano-ruby/master/maestrano.png" alt="Maestrano Logo">
3
+ <br/>
4
+ <br/>
5
+ </p>
6
+
7
+ # Nex!™ Client
8
+
9
+ NexClient is both a ruby client and a command line tool for Nex!™ PaaS
10
+
11
+ ## Install
12
+
13
+ You can install the gem by running:
14
+ ```bash
15
+ gem install nex_cli
16
+ ```
17
+
18
+ ## Getting started with the cli
19
+
20
+ Configure your environment and get started with the tool
21
+ ```bash
22
+ # Set authentication and environment
23
+ export NEX_API_KEY=my-nex-key
24
+ export NEX_ENV=<development|uat|production> # optional - defaulting to 'uat' at the moment
25
+
26
+ # Display all available commands
27
+ nex-cli --help
28
+ ```
data/bin/nex-cli ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require 'nex_client/cli'
6
+
7
+ NexClient::Cli.new.run
data/lib/nex_client.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ require 'json_api_client'
3
+ require 'active_support/all'
4
+ require 'nex_client/version'
5
+
6
+ module NexClient
7
+ autoload :Addon, 'nex_client/addon'
8
+ autoload :App, 'nex_client/app'
9
+ autoload :BaseResource, 'nex_client/base_resource'
10
+ autoload :ComputeRack, 'nex_client/compute_rack'
11
+ autoload :CubeInstance, 'nex_client/cube_instance'
12
+ autoload :CubeTemplate, 'nex_client/cube_template'
13
+ autoload :Domain, 'nex_client/domain'
14
+ autoload :GatewayRack, 'nex_client/gateway_rack'
15
+ autoload :Organization, 'nex_client/organization'
16
+ autoload :RoutingRack, 'nex_client/routing_rack'
17
+ autoload :SslCertificate, 'nex_client/ssl_certificate'
18
+ autoload :StorageRack, 'nex_client/storage_rack'
19
+ autoload :User, 'nex_client/user'
20
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ module NexClient
3
+ class Addon < BaseResource
4
+ property :created_at, type: :time
5
+ property :updated_at, type: :time
6
+ end
7
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ module NexClient
3
+ class App < BaseResource
4
+ property :created_at, type: :time
5
+ property :updated_at, type: :time
6
+ property :ssl_enabled, type: :boolean
7
+ property :persistent_storage, type: :boolean
8
+
9
+ # PATCH <api_root>/apps/:id/restart
10
+ custom_endpoint :restart, on: :member, request_method: :patch
11
+
12
+ # PATCH <api_root>/apps/:id/scale_up
13
+ custom_endpoint :scale_up, on: :member, request_method: :patch
14
+
15
+ # PATCH <api_root>/apps/:id/scale_down
16
+ custom_endpoint :scale_down, on: :member, request_method: :patch
17
+
18
+ # PATCH <api_root>/apps/:id/link_scm
19
+ custom_endpoint :link_scm, on: :member, request_method: :patch
20
+
21
+ # PATCH <api_root>/apps/:id/unlink_scm
22
+ custom_endpoint :unlink_scm, on: :member, request_method: :patch
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ module NexClient
3
+ class BaseResource < JsonApiClient::Resource
4
+ API_HOST = {
5
+ 'development' => 'http://localhost:5000',
6
+ 'uat' => 'https://api-nex-uat.maestrano.io',
7
+ 'production' => 'https://api-nex.maestrano.com',
8
+ }
9
+ API_ROOT_PATH = '/api/v1'
10
+ ENVIRONMENT = ENV['NEX_ENV'] || 'uat' # should be eventually be changed to production
11
+
12
+ self.site = "#{API_HOST[ENVIRONMENT]}#{API_ROOT_PATH}"
13
+ end
14
+ end
15
+
16
+ NexClient::BaseResource.connection do |connection|
17
+ # Set Auth
18
+ connection.use Faraday::Request::BasicAuthentication, ENV['NEX_API_KEY'], ''
19
+ end
@@ -0,0 +1,348 @@
1
+ # frozen_string_literal: true
2
+ require 'commander'
3
+ require 'terminal-table'
4
+ require 'nex_client'
5
+ require 'nex_client/commands'
6
+
7
+ module NexClient
8
+ class Cli
9
+ include Commander::Methods
10
+ # include whatever modules you need
11
+
12
+ def run
13
+ program :name, 'nex-cli'
14
+ program :version, NexClient::VERSION
15
+ program :description, 'Nex!™ PaaS Client'
16
+ default_command :help
17
+
18
+ command :addons do |c|
19
+ c.syntax = 'nex-cli addons [APP_NAME] [options]'
20
+ c.summary = 'Manage addons'
21
+ c.description = 'List addons'
22
+ c.example 'list all active addons', 'nex-cli addons'
23
+ c.example 'list all active addons for myapp', 'nex-cli addons myapp'
24
+ c.example 'list all including terminated addons', 'nex-cli addons --all'
25
+ c.option '--all', 'list all addons (no filtering)'
26
+ c.option '--status <active|terminated>', String, 'list all addons in a given status'
27
+ c.option '--service <mysql|redis>', String, 'list all addons for a specific service'
28
+ c.action do |args, options|
29
+ NexClient::Commands::Addons.list(args,options)
30
+ end
31
+ end
32
+
33
+ command :'addons:create' do |c|
34
+ c.syntax = 'nex-cli addons:create SERVICE APP_NAME'
35
+ c.summary = 'Create addons'
36
+ c.description = 'Create addons for your apps'
37
+ c.example 'create mysql addon for myapp', 'nex-cli addons:create mysql myapp'
38
+ c.example 'create redis addon for myapp', 'nex-cli addons:create redis myapp'
39
+ c.action do |args, options|
40
+ NexClient::Commands::Addons.create(args,options)
41
+ end
42
+ end
43
+
44
+ command :'addons:delete' do |c|
45
+ c.syntax = 'nex-cli addons:delete ADDON_NAME'
46
+ c.summary = 'Delete addons'
47
+ c.description = 'Permanently delete an addons'
48
+ c.example 'delete addon my-addon', 'nex-cli addons:delete my-addon'
49
+ c.action do |args, options|
50
+ NexClient::Commands::Addons.destroy(args,options)
51
+ end
52
+ end
53
+
54
+ command :apps do |c|
55
+ c.syntax = 'nex-cli apps [options]'
56
+ c.summary = 'Manage apps'
57
+ c.description = 'List, create, manage, scale and delete apps'
58
+ c.example 'list all active apps', 'nex-cli apps'
59
+ c.example 'list all active apps for owner myorg', 'nex-cli apps --owner myorg'
60
+ c.example 'list all terminated apps', 'nex-cli apps --status terminated'
61
+ c.example 'list all terminated apps for owner myorg', 'nex-cli apps --status terminated --owner myorg'
62
+ c.option '--all', 'list all apps (no filtering)'
63
+ c.option '--status <active|terminated>', String, 'list all apps in a given status'
64
+ c.option '--ssl', 'list all apps with SSL enabled'
65
+ c.option '--storage', 'list all apps with persistent storage'
66
+ c.option '--owner HANDLE', 'list all apps for the specified owner'
67
+ c.action do |args, options|
68
+ NexClient::Commands::Apps.list(args,options)
69
+ end
70
+ end
71
+
72
+ command :'apps:create' do |c|
73
+ c.syntax = 'nex-cli apps:create DOCKER_IMAGE[:tag] [options]'
74
+ c.summary = 'Create apps'
75
+ c.description = 'Create new docker applications'
76
+ c.example 'create new rails application', 'nex-cli apps:create rails'
77
+ c.option '--env MYVAR=value,MYVAR2=value,...', Array, 'comma separated list of env variables'
78
+ c.option '--env-file FILE', 'newline separated list of env variables'
79
+ c.option '--no-ssl', 'disable SSL support (enabled by default)'
80
+ c.option '--storage', 'enable persistent storage (/!\ only one node allowed)'
81
+ c.option '--owner ORGANIZATION_HANDLE', 'specify an organisation as owner (organization admin only)'
82
+ c.action do |args, options|
83
+ NexClient::Commands::Apps.create(args,options)
84
+ end
85
+ end
86
+
87
+ command :'apps:delete' do |c|
88
+ c.syntax = 'nex-cli apps:delete APP_NAME'
89
+ c.summary = 'Delete an app'
90
+ c.description = 'Permanently delete an app'
91
+ c.example 'delete my-awesome-app', 'nex-cli apps:delete my-awesome-app'
92
+ c.action do |args, options|
93
+ NexClient::Commands::Apps.destroy(args,options)
94
+ end
95
+ end
96
+
97
+ command :'apps:down' do |c|
98
+ c.syntax = 'nex-cli apps:down APP_NAME [options]'
99
+ c.summary = 'Scale applications down'
100
+ c.description = 'Bring nodes down for a given application'
101
+ c.example 'scale myapp down by removing one node', 'nex-cli apps:down myapp'
102
+ c.example 'scale myapp down by removing two nodes', 'nex-cli apps:down myapp --count 2'
103
+ c.option '--count NUMBER', String, 'number of nodes to bring down'
104
+ c.action do |args, options|
105
+ NexClient::Commands::Apps.scale(:down,args,options)
106
+ end
107
+ end
108
+
109
+ command :'apps:info' do |c|
110
+ c.syntax = 'nex-cli apps:info APP_NAME [options]'
111
+ c.summary = 'Show information about an app'
112
+ c.description = 'Show all details about an app'
113
+ c.example 'show details about myapp', 'nex-cli apps:info myapp'
114
+ c.action do |args, options|
115
+ NexClient::Commands::Apps.info(args,options)
116
+ end
117
+ end
118
+
119
+ command :'apps:restart' do |c|
120
+ c.syntax = 'nex-cli apps:restart APP_NAME'
121
+ c.summary = 'Restart an app'
122
+ c.description = 'Initiate a phased restart of an app'
123
+ c.example 'phase-restart my-awesome-app', 'nex-cli apps:restart my-awesome-app'
124
+ c.action do |args, options|
125
+ NexClient::Commands::Apps.restart(args,options)
126
+ end
127
+ end
128
+
129
+ command :'apps:scm' do |c|
130
+ c.syntax = 'nex-cli apps:scm APP_NAME [options]'
131
+ c.summary = 'Manage the SCM of your apps'
132
+ c.description = 'Link/unlink an SCM (e.g. github) to your applications'
133
+ c.example 'link myapp to github using some/repo on branch master', 'nex-cli apps:scm myapp --link github:some/repo'
134
+ c.example 'link myapp to github using some/repo on branch develop', 'nex-cli apps:scm myapp --link github:some/repo:develop'
135
+ c.option '--link <provider>:<repo>[:branch]', String, 'link your SCM repo to this application (only github supported)'
136
+ c.option '--unlink', 'unlink your SCM from the application'
137
+ c.action do |args, options|
138
+ NexClient::Commands::Apps.manage_scm(args,options)
139
+ end
140
+ end
141
+
142
+ command :'apps:up' do |c|
143
+ c.syntax = 'nex-cli apps:up APP_NAME [options]'
144
+ c.summary = 'Scale applications up'
145
+ c.description = 'Add nodes to a given application'
146
+ c.example 'scale myapp up by adding one node', 'nex-cli apps:up myapp'
147
+ c.example 'scale myapp up by adding two nodes', 'nex-cli apps:up myapp --count 2'
148
+ c.option '--count NUMBER', String, 'number of nodes to bring up'
149
+ c.action do |args, options|
150
+ NexClient::Commands::Apps.scale(:up,args,options)
151
+ end
152
+ end
153
+
154
+ command :'apps:vars' do |c|
155
+ c.syntax = 'nex-cli apps:vars APP_NAME [options]'
156
+ c.summary = 'Manage app environment variables'
157
+ c.description = 'List and update environment variables for an app'
158
+ c.example 'list all env variables for myapp', 'nex-cli apps:vars myapp'
159
+ c.example 'Add env variables to myapp', 'nex-cli apps:vars myapp --add MYVAR1=VAL1,MYVAR2=VAL2'
160
+ c.example 'Delete env variables from myapp', 'nex-cli apps:vars myapp --delete MYVAR,MYVAR'
161
+ c.option '--add MYVAR=value,MYVAR2=value,...', Array, 'comma separated list of env variables'
162
+ c.option '--delete MYVAR,MYVAR2,...', Array, 'comma separated list of env variables'
163
+ c.action do |args, options|
164
+ NexClient::Commands::Apps.manage_vars(args,options)
165
+ end
166
+ end
167
+
168
+ command :cubes do |c|
169
+ c.syntax = 'nex-cli cubes [options]'
170
+ c.summary = 'Manage cubes [platform admin]'
171
+ c.description = 'List, create, manage, scale and delete cubes'
172
+ c.example 'list all running cubes', 'nex-cli cubes'
173
+ c.example 'list all running cubes for owner myorg', 'nex-cli cubes --owner myorg'
174
+ c.example 'list all terminated cubes', 'nex-cli cubes --status terminated'
175
+ c.example 'list all terminated cubes for owner myorg', 'nex-cli cubes --status terminated --owner myorg'
176
+ c.example 'list cube xyz.domain.co', 'nex-cli cubes --name xyz.domain.co'
177
+ c.example 'list cube xyz', 'nex-cli cubes --name xyz'
178
+ c.option '--all', 'list all cubes (no filtering)'
179
+ c.option '--status <provisioning|running|stopped|terminated>', String, 'list all cubes in a given status'
180
+ c.option '--ssl', 'list all cubes with SSL enabled'
181
+ c.option '--storage', 'list all cubes with persistent storage'
182
+ c.option '--soa', 'list all apps with soa enabled [legacy]'
183
+ c.option '--dns DNS_NAME', 'list cube by dns (xyz.domain.com) or root dns (xyz)'
184
+ c.option '--app APP_NAME', 'list all cubes attached to the specified app'
185
+ c.option '--addon ADDON_NAME', 'list all cubes attached to the specified addon'
186
+ c.option '--owner HANDLE', 'list all cubes for the specified owner'
187
+ c.action do |args, options|
188
+ NexClient::Commands::CubeInstances.list(args,options)
189
+ end
190
+ end
191
+
192
+ command :'cubes:restart' do |c|
193
+ c.syntax = 'nex-cli cubes:restart CUBE_NAME'
194
+ c.summary = 'Restart a cube'
195
+ c.description = 'Restart a cube'
196
+ c.example 'restart cube xyz', 'nex-cli cubes:restart xyz'
197
+ c.action do |args, options|
198
+ NexClient::Commands::CubeInstances.trigger_action(:restart,args,options)
199
+ end
200
+ end
201
+
202
+ command :'cubes:start' do |c|
203
+ c.syntax = 'nex-cli cubes:start CUBE_NAME'
204
+ c.summary = 'Start a cube'
205
+ c.description = 'Start a cube'
206
+ c.example 'start cube xyz', 'nex-cli cubes:start xyz'
207
+ c.action do |args, options|
208
+ NexClient::Commands::CubeInstances.trigger_action(:start,args,options)
209
+ end
210
+ end
211
+
212
+ command :'cubes:stop' do |c|
213
+ c.syntax = 'nex-cli cubes:stop CUBE_NAME'
214
+ c.summary = 'Stop a cube'
215
+ c.description = 'Stop a cube'
216
+ c.example 'stop cube xyz', 'nex-cli cubes:stop xyz'
217
+ c.action do |args, options|
218
+ NexClient::Commands::CubeInstances.trigger_action(:stop,args,options)
219
+ end
220
+ end
221
+
222
+ command :cube_templates do |c|
223
+ c.syntax = 'nex-cli cube_templates [options]'
224
+ c.summary = 'Manage cube_templates [platform admin][legacy]'
225
+ c.description = 'List, create, manage, scale and delete cube templates'
226
+ c.example 'list all templates', 'nex-cli cube_templates'
227
+ c.example 'list all docker templates', 'nex-cli cube_templates --stack docker'
228
+ c.example 'list specific template', 'nex-cli cube_templates --name mytemplate'
229
+ c.example 'list templates using image someimage', 'nex-cli cube_templates --image someimage'
230
+ c.option '--stack <lxc|docker>', 'list all templates for the specified stack'
231
+ c.option '--name TEMPLATE_NAME', 'list specific template'
232
+ c.option '--image IMAGE_NAME', 'list templates using a specific image'
233
+ c.action do |args, options|
234
+ NexClient::Commands::CubeTemplates.list(args,options)
235
+ end
236
+ end
237
+
238
+ command :domains do |c|
239
+ c.syntax = 'nex-cli domains [APP_NAME] [options]'
240
+ c.summary = 'Manage domains'
241
+ c.description = 'List domains'
242
+ c.example 'list all domains', 'nex-cli addons'
243
+ c.example 'list all domains matching example.com', 'nex-cli domains --domain example.com'
244
+ c.option '--domain', 'list all domains matching the provided cname'
245
+ c.action do |args, options|
246
+ NexClient::Commands::Domains.list(args,options)
247
+ end
248
+ end
249
+
250
+ command :'domains:create' do |c|
251
+ c.syntax = 'nex-cli domains:create CNAME APP_NAME'
252
+ c.summary = 'Create domains'
253
+ c.description = 'Create domains for your apps'
254
+ c.example 'create some.example.com cname for myapp', 'nex-cli domains:create some.example.com myapp'
255
+ c.action do |args, options|
256
+ NexClient::Commands::Domains.create(args,options)
257
+ end
258
+ end
259
+
260
+ command :'domains:delete' do |c|
261
+ c.syntax = 'nex-cli domains:delete CNAME'
262
+ c.summary = 'Delete domains'
263
+ c.description = 'Permanently delete a domain'
264
+ c.example 'delete domain some.example.com', 'nex-cli domains:delete some.example.com'
265
+ c.action do |args, options|
266
+ NexClient::Commands::Domains.destroy(args,options)
267
+ end
268
+ end
269
+
270
+ command :organizations do |c|
271
+ c.syntax = 'nex-cli organizations [options]'
272
+ c.summary = 'List organizations'
273
+ c.description = 'List organizations'
274
+ c.example 'list all organizations', 'nex-cli organizations'
275
+ c.action do |args, options|
276
+ NexClient::Commands::Organizations.list(args,options)
277
+ end
278
+ end
279
+
280
+ command :racks do |c|
281
+ c.syntax = 'nex-cli racks [options]'
282
+ c.summary = 'Manage racks [platform admin]'
283
+ c.description = 'List, create, manage, delete racks'
284
+ c.example 'list all running racks', 'nex-cli racks'
285
+ c.example 'list all running racks', 'nex-cli racks --status running'
286
+ c.example 'list all stopped racks', 'nex-cli racks --status stopped'
287
+ c.example 'list all terminated racks', 'nex-cli racks --status terminated'
288
+ c.example 'list all racks', 'nex-cli racks --all'
289
+ c.option '--all', 'list all racks (no filtering)'
290
+ c.option '--status <provisioning|running|stopped|terminated>', String, 'list all racks in a given status'
291
+ c.option '--type <compute|storage|routing|gateway>', String, 'list all racks of the specified type'
292
+ c.option '--stack <lxc|docker>', String, 'list all compute racks for the specified stack'
293
+ c.action do |args, options|
294
+ NexClient::Commands::Racks.list(args,options)
295
+ end
296
+ end
297
+
298
+ command :certs do |c|
299
+ c.syntax = 'nex-cli certs [APP_NAME] [options]'
300
+ c.summary = 'Manage certs'
301
+ c.description = 'List ssl certificates'
302
+ c.example 'list all certs', 'nex-cli certs'
303
+ c.example 'list all certs matching example.com', 'nex-cli certs --domain example.com'
304
+ c.option '--domain', 'list all certs matching the provided cname'
305
+ c.action do |args, options|
306
+ NexClient::Commands::SslCertificates.list(args,options)
307
+ end
308
+ end
309
+
310
+ command :'certs:create' do |c|
311
+ c.syntax = 'nex-cli certs:create CNAME APP_NAME'
312
+ c.summary = 'Create ssl certificates'
313
+ c.description = 'Create certs for your apps'
314
+ c.example 'create some.example.com certificate for myapp', 'nex-cli certs:create some.example.com myapp'
315
+ c.option '--cert CERT_PATH', String, 'path to pem certificate'
316
+ c.option '--bundle BUNDLE_PATH', String, 'path to certificate bundle'
317
+ c.option '--privkey KEY_PATH', String, 'path to certificate private key'
318
+ c.action do |args, options|
319
+ NexClient::Commands::SslCertificates.create(args,options)
320
+ end
321
+ end
322
+
323
+ command :'certs:delete' do |c|
324
+ c.syntax = 'nex-cli certs:delete CNAME'
325
+ c.summary = 'Delete certs'
326
+ c.description = 'Permanently delete a ssl certificate'
327
+ c.example 'delete certificate for some.example.com', 'nex-cli certs:delete some.example.com'
328
+ c.action do |args, options|
329
+ NexClient::Commands::SslCertificates.destroy(args,options)
330
+ end
331
+ end
332
+
333
+ command :users do |c|
334
+ c.syntax = 'nex-cli users [options]'
335
+ c.summary = 'List users'
336
+ c.description = 'List users'
337
+ c.example 'list all users', 'nex-cli users'
338
+ c.example 'list all users in doecorp organization', 'nex-cli users --organization doecorp'
339
+ c.option '--organization ORG_HANDLE', String, 'list all users in the specified organization'
340
+ c.action do |args, options|
341
+ NexClient::Commands::Users.list(args,options)
342
+ end
343
+ end
344
+
345
+ run!
346
+ end
347
+ end
348
+ end