pi 0.1.23 → 0.1.24

Sign up to get free protection for your applications and to get access to all the features.
data/lib/cli/runner.rb CHANGED
@@ -24,15 +24,27 @@ class PI::Cli::Runner
24
24
  def parse_options!
25
25
  opts_parser = OptionParser.new do |opts|
26
26
  opts.banner = "\nAvailable options:\n\n"
27
+
28
+ opts.on('--url URL') { |url| @options[:url] = url }
29
+ opts.on('--user USER') { |user| @options[:user] = user }
30
+ opts.on('--password PASS') { |pass| @options[:password] = pass }
31
+ opts.on('--name NAME') { |name| @options[:name] = name }
32
+ opts.on('--email EMAIL') { |email| @options[:email] = email }
33
+ opts.on('--path PATH') { |path| @options[:path] = path }
34
+ opts.on('--ver VERSION') { |version| @options[:ver] = version }
35
+ opts.on('--desc DESC') { |desc| @options[:desc] = desc }
36
+ opts.on('--project PROJ') { |proj| @options[:project] = proj }
37
+ opts.on('--target TARG') { |targ| @options[:target] = targ }
38
+ opts.on('--instance N') { |inst| @options[:instance] = inst }
27
39
  # generic tracing and debugging
28
- opts.on('-t [TKEY]') { |tkey| @options[:trace] = tkey || true }
29
- opts.on('--trace [TKEY]') { |tkey| @options[:trace] = tkey || true }
30
- opts.on('-q', '--quiet') { @options[:quiet] = true }
31
- opts.on('--verbose') { @options[:verbose] = true }
32
- opts.on('--json') { @options[:json] = true }
33
- opts.on('-v', '--version') { set_cmd(:misc, :version) }
34
- opts.on('-h', '--help') { puts "#{command_usage}\n"; exit }
35
- opts.on_tail('--options') { puts "#{opts}\n"; exit }
40
+ opts.on('-t [TKEY]') { |tkey| @options[:trace] = tkey || true }
41
+ opts.on('--trace [TKEY]') { |tkey| @options[:trace] = tkey || true }
42
+ opts.on('-q', '--quiet') { @options[:quiet] = true }
43
+ opts.on('--verbose') { @options[:verbose] = true }
44
+ opts.on('--json') { @options[:json] = true }
45
+ opts.on('-v', '--version') { set_cmd(:misc, :version) }
46
+ opts.on('-h', '--help') { puts "#{command_usage}\n"; exit }
47
+ opts.on_tail('--options') { puts "#{opts}\n"; exit }
36
48
  end
37
49
  instances_delta_arg = check_instances_delta!
38
50
  @args = opts_parser.parse!(@args)
@@ -85,8 +97,12 @@ class PI::Cli::Runner
85
97
  ###############################################################################
86
98
 
87
99
  when 'login'
88
- usage('pi login [url]')
89
- set_cmd(:user, :login, @args.size == 1 ? 1 : 0)
100
+ usage('pi login [url] [--user USER] [--password PASS]')
101
+ if @args.size == 1
102
+ set_cmd(:user, :login, 1)
103
+ else
104
+ set_cmd(:user, :login)
105
+ end
90
106
 
91
107
  when 'logout'
92
108
  usage('pi logout')
@@ -109,8 +125,12 @@ class PI::Cli::Runner
109
125
  set_cmd(:user, :password, @args.size == 1 ? 1 : 0)
110
126
 
111
127
  when 'github'
112
- usage ('pi github [name]')
113
- set_cmd(:user, :github,@args.size == 1 ? 1 : 0)
128
+ usage ('pi github [name] [--email EMAIL] [--password PASS]')
129
+ if @args.size == 1
130
+ set_cmd(:user, :github, 1)
131
+ else
132
+ set_cmd(:user, :github)
133
+ end
114
134
 
115
135
  when 'runtimes'
116
136
  usage('pi runtimes')
@@ -150,87 +170,91 @@ class PI::Cli::Runner
150
170
  set_cmd(:projects, :projects)
151
171
 
152
172
  when 'create-project'
153
- usage('pi create-project [projectname]')
154
- set_cmd(:projects, :create_project, @args.size == 1 ? 1 : 0)
173
+ usage('pi create-project [project]')
174
+ set_cmd(:projects, :create_project, @args.size == 1 ? 1 : 0)
155
175
 
156
176
  when 'delete-project'
157
- usage('pi delete-project [projectname]')
177
+ usage('pi delete-project [project]')
158
178
  set_cmd(:projects, :delete_project, @args.size == 1 ? 1 : 0)
159
179
 
160
180
  when 'upload'
161
- usage('pi upload [projectname]')
162
- set_cmd(:projects, :upload, @args.size == 1 ? 1 : 0)
181
+ usage('pi upload [project] [--path PATH] [--ver VERSION] [--desc DESC]')
182
+ if @args.size == 1
183
+ set_cmd(:projects, :upload, 1)
184
+ else
185
+ set_cmd(:projects, :upload)
186
+ end
187
+
188
+ when 'delete-binary'
189
+ usage('pi delete-binary [project]')
190
+ set_cmd(:projects, :delete_binary, @args.size == 1 ? 1 : 0)
163
191
 
164
192
  when 'project-events'
165
- usage('pi project-events [projectname]')
193
+ usage('pi project-events [project]')
166
194
  set_cmd(:projects, :project_events, @args.size == 1 ? 1 : 0)
167
195
 
168
196
  when 'project-tags'
169
- usage('pi project-tags [projectname]')
197
+ usage('pi project-tags [project]')
170
198
  set_cmd(:projects, :project_tags, @args.size == 1 ? 1 : 0)
171
199
 
172
200
  when 'project-commits'
173
- usage('pi project-commits [projectname]')
201
+ usage('pi project-commits [project]')
174
202
  set_cmd(:projects, :project_commits, @args.size == 1 ? 1 : 0)
175
-
176
- when 'project-apps'
177
- usage('pi project-apps [projectname]')
178
- set_cmd(:projects, :project_apps, @args.size == 1 ? 1 : 0)
179
203
 
180
204
  ###############################################################################
181
205
  # Applications
182
206
  ###############################################################################
183
207
 
184
208
  when 'apps'
185
- usage('pi apps [projectid]')
186
- set_cmd(:apps, :apps, @args.size == 1 ? 1 : 0)
209
+ usage('pi apps [--project PROJ] [--target TARG]')
210
+ set_cmd(:apps, :apps)
187
211
 
188
212
  when 'create-app'
189
213
  usage('pi create-app [appname]')
190
214
  set_cmd(:apps, :create_app, @args.size == 1 ? 1 : 0)
191
215
 
192
216
  when 'delete-app'
193
- usage('pi delete-app [appid]')
217
+ usage('pi delete-app [appid] or pi delete-app <appname> <--target TARGET>')
194
218
  set_cmd(:apps, :delete_app, @args.size == 1 ? 1 : 0)
195
219
 
196
220
  when 'start-app'
197
- usage('pi start-app [appid]')
198
- set_cmd(:apps, :start_app, @args.size == 1 ? 1 : 0)
221
+ usage('pi start-app [appid] or pi start-app <appname> <--target TARGET>')
222
+ set_cmd(:apps, :start_app, @args.size == 1 ? 1 : 0)
199
223
 
200
224
  when 'stop-app'
201
- usage('pi stop-app [appid]')
225
+ usage('pi stop-app [appid] or pi stop-app <appname> <--target TARGET>')
202
226
  set_cmd(:apps, :stop_app, @args.size == 1 ? 1 : 0)
203
227
 
204
228
  when 'restart-app'
205
- usage('pi restart-app [appid]')
229
+ usage('pi restart-app [appid] or pi restart-app <appname> <--target TARGET>')
206
230
  set_cmd(:apps, :restart_app, @args.size == 1 ? 1 : 0)
207
231
 
208
232
  when 'scale-app'
209
- usage('pi scale-app [appid]')
233
+ usage('pi scale-app [appid] [--instance N] or pi scale-app <appname> <--target TARGET> [--instance N]')
210
234
  set_cmd(:apps, :scale_app, @args.size == 1 ? 1 : 0)
211
235
 
212
236
  when 'update-app'
213
- usage('pi update-app [appid]')
237
+ usage('pi update-app [appid] or pi update-app <appname> <--target TARGET>')
214
238
  set_cmd(:apps, :update_app, @args.size == 1 ? 1 : 0)
215
239
 
216
240
  when 'status'
217
- usage('pi status [appname]')
241
+ usage('pi status-app [appid] or pi status-app <appname> <--target TARGET>')
218
242
  set_cmd(:apps, :status, @args.size == 1 ? 1 : 0)
219
243
 
220
244
  when 'app-env'
221
- usage('pi app-env [appname]')
245
+ usage('pi start-app [appid] or pi start-app <appname> <--target TARGET>')
222
246
  set_cmd(:apps, :app_env, @args.size == 1 ? 1 : 0)
223
247
 
224
248
  when 'create-env'
225
- usage('pi create-env [appname]')
249
+ usage('pi app-env [appid] or pi app-env <appname> <--target TARGET>')
226
250
  set_cmd(:apps, :create_env, @args.size == 1 ? 1 : 0)
227
251
 
228
252
  when 'delete-env'
229
- usage('pi delete-env [appname]')
253
+ usage('pi delete-env [appid] or pi delete-env <appname> <--target TARGET>')
230
254
  set_cmd(:apps, :delete_env, @args.size == 1 ? 1 : 0)
231
255
 
232
256
  when 'app-log'
233
- usage('pi app-log [appid]')
257
+ usage('pi app-log [appid] or pi app-log <appname> <--target TARGET>')
234
258
  set_cmd(:apps, :app_log, @args.size == 1 ? 1 : 0)
235
259
 
236
260
  ###############################################################################
@@ -238,15 +262,15 @@ class PI::Cli::Runner
238
262
  ###############################################################################
239
263
 
240
264
  when 'app-service'
241
- usage('pi app-service [appname]')
265
+ usage('pi app-service [appid] or pi app-service <appname> <--target TARGET>')
242
266
  set_cmd(:services, :app_service, @args.size == 1 ? 1 : 0)
243
267
 
244
268
  when 'bind-service'
245
- usage('pi bind-service [appname]')
269
+ usage('pi bind-service [appid] or pi bind-service <appname> <--target TARGET>')
246
270
  set_cmd(:services, :bind_service, @args.size == 1 ? 1 : 0)
247
271
 
248
272
  when 'unbind-service'
249
- usage('pi unbind-service [appname]')
273
+ usage('pi unbind-service [appid] or pi unbind-service <appname> <--target TARGET>')
250
274
  set_cmd(:services, :unbind_service, @args.size == 1 ? 1 : 0)
251
275
 
252
276
  ###############################################################################
@@ -254,25 +278,17 @@ class PI::Cli::Runner
254
278
  ###############################################################################
255
279
 
256
280
  when 'app-dns'
257
- usage('pi app-dns [appname]')
281
+ usage('pi app-dns [appid] or pi app-dns <appname> <--target TARGET>')
258
282
  set_cmd(:dns, :app_dns, @args.size == 1 ? 1 : 0)
259
283
 
260
284
  when 'map-dns'
261
- usage('pi map-dns [appname]')
285
+ usage('pi map-dns [appid] or pi map-dns <appname> <--target TARGET>')
262
286
  set_cmd(:dns, :map_dns, @args.size == 1 ? 1 : 0)
263
287
 
264
288
  when 'unmap-dns'
265
- usage('pi unmap-dns [appname]')
289
+ usage('pi unmap-dns [appid] or pi unmap-dns <appname> <--target TARGET>')
266
290
  set_cmd(:dns, :unmap_dns, @args.size == 1 ? 1 : 0)
267
-
268
- ###############################################################################
269
- # Admin
270
- ###############################################################################
271
-
272
- when 'users'
273
- usage('pi users')
274
- set_cmd(:admin, :users)
275
-
291
+
276
292
  ###############################################################################
277
293
 
278
294
  when 'usage'
@@ -310,7 +326,15 @@ class PI::Cli::Runner
310
326
  PI::Cli::Config.trace = @options.delete(:trace)
311
327
  PI::Cli::Config.output ||= STDOUT unless @options[:quiet]
312
328
 
329
+ # local shopts=$-
330
+ # set -o noglob
331
+ Kernel.system('set -o noglob')
332
+ # Kernel.exec('sudo set -o noglob')
333
+ # `set -o noglob`
313
334
  parse_command!
335
+ # system('set +o noglob')
336
+ # set +o noglob
337
+ # set -$shopts
314
338
  if @namespace && @action
315
339
  eval("PI::Cli::Command::#{@namespace.to_s.capitalize}").new(@options).send(@action.to_sym, *@args)
316
340
  elsif @help_only || @usage
data/lib/cli/usage.rb CHANGED
@@ -25,52 +25,68 @@ class PI::Cli::Runner
25
25
  Currently available pi commands are:
26
26
 
27
27
  User
28
- login [url] Login
29
- logout Logs current user out of the system
30
- info List system information
31
- user Display user information
32
- targets List available targets infomation
33
- github [name] Bind to the github account
34
- runtimes Display the supported runtimes of the system
35
- frameworks Display the supported frameworks of the system
36
- version Display version information
37
- help [command] Get general help or help on a specific command
38
- help options Get help on available options
28
+ login [url] [--user,--password] Login
29
+ logout Logs current user out of the system
30
+ info List system information
31
+ user Display user information
32
+ targets List available targets infomation
33
+ github [name] [--email,--password] Bind to the github account
34
+ runtimes Display the supported runtimes of the system
35
+ frameworks Display the supported frameworks of the system
36
+ version Display version information
37
+ help [command] Get general help or help on a specific command
38
+ help options Get help on available options
39
39
 
40
40
  Project
41
- projects List created projects
42
- create-project [projectname] Create a new project
43
- delete-project [projectname] Delete the project
44
- project-events [projectname] List the event info for the project
45
- project-tags [projectname] List the tags for the project
46
- project-commits [projectname] List the commit log for the project
47
- project-apps [projectname] List the applications for the project
48
- upload [projectname] Upload the war package for java project
41
+ projects List created projects
42
+ create-project [project] Create a new project
43
+ delete-project [project] Delete the project
44
+ project-events [project] List the event info for the project
45
+ project-tags [project] List the tags for the project
46
+ project-commits [project] List the commit log for the project
47
+ upload [project][--path,--ver,--desc] Upload the war package for java project
49
48
 
50
- Application
51
- apps List deployed applications for the project
52
- create-app [appname] Create a new application
53
- delete-app [appid] Delete the application
54
- start-app [appid] Start the application
55
- stop-app [appid] Stop the application
56
- restart-app [appid] Restart the application
57
- scale-app [appid] Scale the application instances up or down
58
- update-app [appid] Update the application
59
- status [appname] Display resource usage for the application
60
- app-env [appid] Display the environments for the application
61
- create-env [appid] Create the environment for the application
62
- delete-env [appid] Delete the environment for the application
63
- app-log [appid] List the logs for the application
49
+ Application
50
+ apps [--project,--target] List deployed applications for the project
51
+ create-app [appname] Create a new application
52
+ delete-app [appid] Delete the application
53
+ delete-app <appname> <--target TARGET> Delete the application
54
+ start-app [appid] Start the application
55
+ start-app <appname> <--target TARGET> Start the application
56
+ stop-app [appid] Stop the application
57
+ stop-app <appname> <--target TARGET> Stop the application
58
+ restart-app [appid] Restart the application
59
+ restart-app <appname> <--target TARGET> Restart the application
60
+ scale-app [appid] [--instance N] Scale the application instances up or down
61
+ scale-app <appname> <--target TARGET> [--instance N] Scale the application instances up or down
62
+ update-app [appid] Update the application
63
+ update-app <appname> <--target TARGET> Update the application
64
+ status [appid] Display resource usage for the application
65
+ status <appname> <--target TARGET> Display resource usage for the application
66
+ app-env [appid] Display the environments for the application
67
+ app-env <appname> <--target TARGET> Display the environments for the application
68
+ create-env [appid] Create the environment for the application
69
+ create-env <appname> <--target TARGET> Create the environment for the application
70
+ delete-env [appid] Delete the environment for the application
71
+ delete-env <appname> <--target TARGET> Delete the environment for the application
72
+ app-log [appid] List the logs for the application
73
+ app-log <appname> <--target TARGET> List the logs for the application
64
74
 
65
75
  Service
66
- app-service [appname] Display the bind services for the application
67
- bind-service [appname] Bind a service to an application
68
- unbind-service [appname] Unbind a service to an application
76
+ app-service [appid] Display the binded services for the application
77
+ app-service <appname> <--target TARGET> Display the binded services for the application
78
+ bind-service [appid] Bind the services for the application
79
+ bind-service <appname> <--target TARGET> Bind the services for the application
80
+ unbind-service [appid] Unbind the service for the application
81
+ unbind-service <appname> <--target TARGET> Unbind the service for the application
69
82
 
70
83
  DNS
71
- app-dns [appname] Display the mapped urls for the application
72
- map-dns [appname] Map the url for the application
73
- unmap-dns [appname] Unmap the url for the application
84
+ app-dns [appid] Display the mapped urls for the application
85
+ app-dns <appname> <--target TARGET> Display the mapped urls for the application
86
+ map-dns [appid] Map the urls for the application
87
+ map-dns <appname> <--target TARGET> Map the urls for the application
88
+ unmap-dns [appid] Unmap the url for the application
89
+ unmap-dns <appname> <--target TARGET> Unmap the url for the application
74
90
  USAGE
75
91
 
76
92
  end
data/lib/cli/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module PI
2
2
  module Cli
3
- VERSION = '0.1.23'
3
+ VERSION = '0.1.24'
4
4
  end
5
5
  end
data/lib/pi/client.rb CHANGED
@@ -37,8 +37,23 @@ class PI::Client
37
37
  # Users
38
38
  #####################################################
39
39
 
40
- def check_url
41
- http_get
40
+ def target_valid?
41
+ return false unless descr = info
42
+ return false unless descr[:name]
43
+ return false unless descr[:build]
44
+ return false unless descr[:version]
45
+ return false unless descr[:description]
46
+ true
47
+ rescue
48
+ false
49
+ end
50
+
51
+ def raw_info
52
+ http_get(PI::INFO_PATH)
53
+ end
54
+
55
+ def check_login_status
56
+ raise AuthError unless @auth_token
42
57
  end
43
58
 
44
59
  def login(user, password)
@@ -66,7 +81,8 @@ class PI::Client
66
81
  end
67
82
 
68
83
  def password(newpassword)
69
- status, body, headers = json_post("#{PI::USER_PATH}/password/#{newpassword}",{:newpass => newpassword})
84
+ # status, body, headers = json_post("#{PI::USER_PATH}/password/#{newpassword}",{:newpass => newpassword})
85
+ json_get("#{PI::USER_PATH}/password/#{newpassword}")
70
86
  end
71
87
 
72
88
  def github(manifest={})
@@ -85,20 +101,24 @@ class PI::Client
85
101
  # projects
86
102
  #####################################################
87
103
 
88
- def projects
89
- json_get("#{PI::PROJECT_PATH}/list")
104
+ def project_search(projectname=nil)
105
+ json_get("#{PI::PROJECT_PATH}/search/#{projectname}")
90
106
  end
91
107
 
92
- def project_get(projectname)
93
- json_get("#{PI::PROJECT_PATH}/get?projectName=#{projectname}")
108
+ def projects(pageNum=-1, numPerPage=-1)
109
+ json_get("#{PI::PROJECTS_PATH}/search?pageNum=#{pageNum}&numPerPage=#{numPerPage}")
110
+ end
111
+
112
+ def project_sum
113
+ http_get("#{PI::PROJECTS_PATH}/search/sum")
94
114
  end
95
115
 
96
116
  def create_project(name, manifest={})
97
- status, body, headers = json_post("#{PI::PROJECT_PATH}/create", manifest)
117
+ status, body, headers = json_post("#{PI::PROJECT_PATH}/", manifest)
98
118
  end
99
119
 
100
120
  def delete_project(projectname)
101
- http_delete("#{PI::PROJECT_PATH}/delete/#{projectname}",'application/json')
121
+ http_delete("#{PI::PROJECT_PATH}/#{projectname}",'application/json')
102
122
  end
103
123
 
104
124
  def upload(manifest={})
@@ -106,6 +126,10 @@ class PI::Client
106
126
  response_info = json_parse(body)
107
127
  end
108
128
 
129
+ def delete_binary(binaryid)
130
+ http_delete("#{PI::PROJECT_PATH}/binary/#{binaryid}",'application/json')
131
+ end
132
+
109
133
  def project_events(projectname)
110
134
  json_get("#{PI::PROJECT_PATH}/events/#{projectname}")
111
135
  end
@@ -118,145 +142,136 @@ class PI::Client
118
142
  json_get("#{PI::PROJECT_PATH}/commitinfo/#{projectname}/#{tag}")
119
143
  end
120
144
 
121
- def project_apps(projectname)
122
- json_get("#{PI::PROJECT_PATH}/apps/#{projectname}")
145
+ def project_binary(projectname)
146
+ json_get("#{PI::PROJECT_PATH}/binary/list/#{projectname}")
123
147
  end
124
148
 
125
- def project_binary(projectid)
126
- json_get("#{PI::PROJECT_PATH}/binary/list?query=project_id%3D#{projectid}")
149
+ def project_binary_existed(projectname,versionname)
150
+ http_get("#{PI::PROJECT_PATH}/binary/existed/#{projectname}/#{versionname}")
127
151
  end
128
152
 
129
153
  def project_branchs(projectname)
130
154
  json_get("#{PI::PROJECT_PATH}/branchs/#{projectname}")
131
155
  end
156
+
157
+ def apps(projectname=nil, targetname=nil, pageNum=-1, numPerPage=-1)
158
+ json_get("#{PI::PROJECT_PATH}/apps?projectName=#{projectname}&targetName=#{targetname}&pageNum=#{pageNum}&numPerPage=#{numPerPage}")
159
+ end
160
+
161
+ def app_sum(projectname=nil, targetname=nil)
162
+ http_get("#{PI::PROJECT_PATH}/apps/sum?projectName=#{projectname}&targetName=#{targetname}")
163
+ end
132
164
 
133
165
  #####################################################
134
166
  # applications
135
167
  #####################################################
136
168
 
137
- def apps(projectid, queryParam = nil)
138
- queryParam = { :pageNum => -1, :NumPerPage => -1} unless queryParam
139
- json_get("#{PI::APP_PATH}/list?projectId=#{projectid}&pageNum=#{queryParam[:pageNum]}&numPerPage=#{queryParam[:NumPerPage]}")
169
+ def app_get_byid(appid)
170
+ json_get("#{PI::APP_PATH}/#{appid}")
140
171
  end
141
172
 
142
- def app_sum(projectid)
143
- http_get("#{PI::APP_PATH}/sum?projectId=#{projectid}")
173
+ def app_search(targetname, appname)
174
+ json_get("#{PI::APP_PATH}/search/#{targetname}/#{appname}")
144
175
  end
145
176
 
146
- def app_get_byname(appname)
147
- json_get("#{PI::APP_PATH}/get?appName=#{appname}")
177
+ def app_search_target_is_all(appname)
178
+ json_get("#{PI::PROJECT_PATH}/apps?appName=#{appname}")
148
179
  end
149
180
 
150
- def app_get_byid(appid)
151
- json_get("#{PI::APP_PATH}/get?appId=#{appid}")
152
- end
153
-
154
- def create_app(projectid,manifest={})
155
- status, body, headers = json_post("#{PI::APP_PATH}/create?projectId=#{projectid}", manifest)
181
+ def create_app(manifest={})
182
+ status, body, headers = json_post("#{PI::APP_PATH}/", manifest)
156
183
  end
157
184
 
158
185
  def target_memory(targetname)
159
- http_get("#{PI::APP_PATH}/target/memory?targetName=#{targetname}")
186
+ http_get("#{PI::APP_PATH}/target/#{targetname}/memory")
160
187
  end
161
188
 
162
- def app_message(appname,message)
163
- json_get("#{PI::APP_PATH}/message?appName=#{appname}&eventName=#{message}")
189
+ def app_message(targetname,appname,message)
190
+ json_get("#{PI::APP_PATH}/message/#{targetname}/#{appname}?eventName=#{message}")
164
191
  end
165
192
 
166
193
  def delete_app(appid)
167
- http_delete("#{PI::APP_PATH}/delete?appId=#{appid}",'application/json')
194
+ http_delete("#{PI::APP_PATH}/#{appid}",'application/json')
168
195
  end
169
196
 
170
197
  def start_app(appid)
171
- json_get("#{PI::APP_PATH}/start?appId=#{appid}")
198
+ json_post("#{PI::APP_PATH}/#{appid}/start",manifest={})
172
199
  end
173
200
 
174
201
  def stop_app(appid)
175
- json_get("#{PI::APP_PATH}/stop?appId=#{appid}")
202
+ json_post("#{PI::APP_PATH}/#{appid}/stop",manifest={})
176
203
  end
177
204
 
178
205
  def scale_app(appid,instance)
179
- json_get("#{PI::APP_PATH}/scale?appId=#{appid}&instance=#{instance}")
206
+ json_post("#{PI::APP_PATH}/#{appid}/scale?instance=#{instance}", manifest={})
180
207
  end
181
208
 
182
- def update_app(appid,tag)
183
- json_get("#{PI::APP_PATH}/rollback?appId=#{appid}&tag=#{tag}")
209
+ def update_app(appid, tag)
210
+ json_post("#{PI::APP_PATH}/#{appid}/rollback/#{tag}", manifest={})
184
211
  end
185
212
 
186
- def status(appname)
187
- json_get("#{PI::APP_PATH}/monitor?appName=#{appname}")
213
+ def status(appid)
214
+ json_get("#{PI::APP_PATH}/#{appid}/monitor")
188
215
  end
189
216
 
190
- def app_env(appname)
191
- json_get("#{PI::APP_PATH}/env/list?appName=#{appname}")
192
- end
193
-
194
- def create_env(appname,manifest=nil)
195
- json_post("#{PI::APP_PATH}/env/save?appName=#{appname}",manifest)
217
+ def app_log(appid,filepath,instanceindex)
218
+ http_get("#{PI::APP_PATH}/#{appid}/logs?filePath=#{filepath}&instanceIndex=#{instanceindex}")
196
219
  end
197
220
 
198
- def delete_env(appname,manifest=nil)
199
- json_post("#{PI::APP_PATH}/env/delete?appName=#{appname}",manifest)
221
+ def app_env(appid)
222
+ json_get("#{PI::APP_PATH}/#{appid}/env/list")
223
+ end
224
+
225
+ def create_env(appid, manifest={})
226
+ json_post("#{PI::APP_PATH}/#{appid}/env", manifest)
200
227
  end
201
228
 
202
- def env_verify(appname,name)
203
- http_get("#{PI::APP_PATH}/env/verify?appName=#{appname}&name=#{name}")
229
+ def delete_env(appid, env)
230
+ http_delete("#{PI::APP_PATH}/#{appid}/env/#{env}",'application/json')
204
231
  end
205
232
 
206
- def app_log(appid,filepath,instanceindex)
207
- http_get("#{PI::APP_PATH}/logs?appId=#{appid}&filePath=#{filepath}&instanceIndex=#{instanceindex}")
233
+ def env_verify(appid,name)
234
+ http_get("#{PI::APP_PATH}/#{appid}/env/verify?name=#{name}")
208
235
  end
209
236
 
210
237
  #####################################################
211
238
  # services
212
239
  #####################################################
213
240
 
214
- def usable_services(appname)
215
- json_get("#{PI::APP_PATH}/service/usable?appName=#{appname}")
241
+ def usable_services(appid)
242
+ json_get("#{PI::APP_PATH}/#{appid}/service/usable")
216
243
  end
217
244
 
218
- def app_service(appname)
219
- json_get("#{PI::APP_PATH}/service/binded?appName=#{appname}")
245
+ def app_service(appid)
246
+ json_get("#{PI::APP_PATH}/#{appid}/service/bind")
220
247
  end
221
248
 
222
- def bind_service(appname, manifest=nil)
223
- json_post("#{PI::APP_PATH}/service/bind?appName=#{appname}",manifest)
249
+ def bind_service(appid, manifest={})
250
+ json_post("#{PI::APP_PATH}/#{appid}/service/bind",manifest)
224
251
  end
225
252
 
226
- def unbind_service(appname, manifest=nil)
227
- json_post("#{PI::APP_PATH}/service/unbind?appName=#{appname}",manifest)
253
+ def unbind_service(appid, servicename)
254
+ http_delete("#{PI::APP_PATH}/#{appid}/service/unbind/#{servicename}",'application/json')
228
255
  end
229
256
 
230
257
  #####################################################
231
258
  # dns
232
259
  #####################################################
233
260
 
234
- def usable_dns(appname)
235
- json_get("#{PI::APP_PATH}/url/usable?appName=#{appname}")
261
+ def usable_dns(appid)
262
+ json_get("#{PI::APP_PATH}/#{appid}/url/usable")
236
263
  end
237
264
 
238
- def app_dns(appname)
239
- json_get("#{PI::APP_PATH}/url/mapped?appName=#{appname}")
265
+ def app_dns(appid)
266
+ json_get("#{PI::APP_PATH}/#{appid}/url/map")
240
267
  end
241
268
 
242
- def map_dns(appname, manifest=nil)
243
- json_post("#{PI::APP_PATH}/url/map?appName=#{appname}",manifest)
244
- end
245
-
246
- def unmap_dns(appname, manifest=nil)
247
- json_post("#{PI::APP_PATH}/url/unmap?appName=#{appname}",manifest)
248
- end
249
-
250
- #####################################################
251
- # administration
252
- #####################################################
253
-
254
- def admin_domains
255
- json_get("#{PI::ADMIN_PATH}/domains")
269
+ def map_dns(appid, manifest={})
270
+ json_post("#{PI::APP_PATH}/#{appid}/url/map", manifest)
256
271
  end
257
272
 
258
- def admin_users(domainid)
259
- json_get("#{PI::ADMIN_PATH}/users?query=domain_id%3D#{domainid}")
273
+ def unmap_dns(appid, url)
274
+ http_delete("#{PI::APP_PATH}/#{appid}/url/unmap/#{url}", 'application/json')
260
275
  end
261
276
 
262
277
  ######################################################