app42 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72b1cf90b1aa79d2f2c7d7e07d09f21ad6d50ad0
4
- data.tar.gz: 71e15470863e0a4c288294307c7e812dc2e1cfab
3
+ metadata.gz: b563b365eec3cf93e1160c083f5cc4f22b04b5e2
4
+ data.tar.gz: 78e962500cb7d379345e94b2f3594c774a89b17f
5
5
  SHA512:
6
- metadata.gz: f773373c427bd715180ffdbf4f3eca4b21256e150faee645df1f734eb2044b3f0bbf0f329e608eba93bac2a3fc85b2c08758e909512eaf02db34a5d88fc7f144
7
- data.tar.gz: 91ba3ce9113eb87ed77a00bfbb387669c651fe168ca77211cf78efad251dc009b84214a750d40c2f836f6e77885953b2780a0f6aae908cc6b960aba7e4165199
6
+ metadata.gz: 916f535b002c643f889b1d7e90394d09df490b29213b05cf31c72042aacc10905cd852da210a51eafa5b5ac25ccd726ca5f78528eaccfec46a16b7336d92c100
7
+ data.tar.gz: d84f0c05d59cd4a3f432cd818159bd305f4f43bf82a586b2943d460fe2206a2bdf5c99e84dd5010846394a4cc02da9028092fa7efc0ff68fd9e9462cc7e860d0
data/RELEASE.md CHANGED
@@ -22,4 +22,9 @@ Client library and command-line tool to deploy and manage apps on App42PaaS.
22
22
  - BPaaS setup downgrade
23
23
  - WordPress setup donwgrade
24
24
 
25
+ ### 0.6.1 (22-01-2014)
26
+
27
+ - Add custom URL
28
+ - Remove custom URL
29
+ - List custom URL
25
30
 
@@ -28,8 +28,9 @@ module App42
28
28
  DATABASE_NAME_NOT_ALLOWED = %w(mysql couchdb mongodb postgresql database sql)
29
29
 
30
30
  # regex for special character
31
- SPECIAL = "?<>',?[]}{=-)(*&^%$#`~{}@ .+!_/"
32
- REGEX = /[#{SPECIAL.gsub(/./){|char| "\\#{char}"}}]/
31
+ SPECIAL = "?<>',?[]}{=-)(*&^%$#`~{}@ .+!_/"
32
+ REGEX = /[#{SPECIAL.gsub(/./){|char| "\\#{char}"}}]/
33
+ URL_REGEX = /(((^https?)|(^ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/
33
34
 
34
35
  # regex for special character (Database Name)
35
36
  DBNAME_SPECIAL = "?<>',?[]}{=-)(*&^%$#`~{}@ .+!/"
@@ -45,6 +45,9 @@ module App42
45
45
  appInfo # Show meta information of the application
46
46
  appState # Show current state of the application
47
47
  logs # Returns the log file URL(s) for the application
48
+ addCustomURL # Add a custom URL to an app
49
+ removeCustomURL # Remove a custom URL from an app
50
+ customURLInfo # List all custom URLs of an app
48
51
 
49
52
  Services
50
53
  createService # Creates a new service e.g. MySQL, MongoDB, CouchDB, PostgreSQL etc.
@@ -1092,10 +1095,9 @@ Example:
1092
1095
  $app42 upgradeBPaaS
1093
1096
  Enter Setup Name: demo
1094
1097
 
1095
- 1: Light
1096
- 2: Medium
1097
- 3: Heavy
1098
- Select Flavour [Light]: 2
1098
+ 1: Medium
1099
+ 2: Heavy
1100
+ Select Flavour [Medium]: 2
1099
1101
 
1100
1102
  Upgrading Setup... OK
1101
1103
 
@@ -1208,10 +1210,9 @@ Example:
1208
1210
  $app42 upgradeWordPress
1209
1211
  Enter Setup Name: demo
1210
1212
 
1211
- 1: Light
1212
- 2: Medium
1213
- 3: Heavy
1214
- Select Flavour [Light]: 2
1213
+ 1: Medium
1214
+ 2: Heavy
1215
+ Select Flavour [Medium]: 2
1215
1216
 
1216
1217
  Upgrading Setup... OK
1217
1218
 
@@ -1306,6 +1307,66 @@ Example:
1306
1307
  DESC
1307
1308
  end
1308
1309
 
1310
+ def addcustomurl
1311
+ print <<-DESC
1312
+ Usage:
1313
+ app42 addCustomURL
1314
+
1315
+ Add a custom URL to an app
1316
+
1317
+ Example:
1318
+ $app42 addCustomURL
1319
+ Enter App Name: demo
1320
+
1321
+ Enter Custom URL: http://test.naveengoswami.com
1322
+
1323
+ Adding Custom URL To Application demo... OK
1324
+ Custom URL added successfully.
1325
+
1326
+ DESC
1327
+ end
1328
+
1329
+ def removecustomurl
1330
+ print <<-DESC
1331
+ Usage:
1332
+ app42 removeCustomURL
1333
+
1334
+ Remove a custom URL from an app
1335
+
1336
+ Example:
1337
+ $ app42 removeCustomURL
1338
+ Enter App Name: demo
1339
+
1340
+ Enter Custom URL: http://test.naveengoswami.com
1341
+
1342
+ Removing Custom URL... OK
1343
+ Custom URL deleted successfully.
1344
+
1345
+ DESC
1346
+ end
1347
+
1348
+ def customurlinfo
1349
+ print <<-DESC
1350
+ Usage:
1351
+ app42 customURLInfo
1352
+
1353
+ List all custom URLs of an app
1354
+
1355
+ Example:
1356
+ $app42 customURLInfo
1357
+ Enter App Name: demo
1358
+
1359
+ +----------+-----------------------+-------------------------------+
1360
+ | === testPhp Custome URLs Details === |
1361
+ +----------+-----------------------+-------------------------------+
1362
+ | App Name | Created On | Url |
1363
+ +-------------+-----------------------+----------------------------+
1364
+ | demo | 2014-01-27 06:35:55.0 | http://test.naveengoswami.com |
1365
+ +----------+-----------------------+-------------------------------+
1366
+
1367
+ DESC
1368
+ end
1369
+
1309
1370
  def version
1310
1371
  print <<-DESC
1311
1372
  Usage:
@@ -13,6 +13,7 @@ module Message
13
13
  MORE_THAN_ONE_BINARY = "More than one binary exists at the specified location. Please choose one."
14
14
  NO_BINARY = "No binary exists at the specified location."
15
15
  NO_APP = "No App found."
16
+ NO_CUSTOM_URLS = "No Custom URLs found."
16
17
  WAIT_FOR_WHILE = "Please be patient... This process may take a while to complete."
17
18
  LATEST_S_WAIT = "\nOperation is in progress, Please wait..."
18
19
  LATEST_S_INTERRUPT = "\nYour request is being processed. Please check the request status after sometime."
@@ -37,6 +38,6 @@ module Message
37
38
  BAD_RESPONSE_ERROR = "Received bad HTTP response from"
38
39
 
39
40
  # BPaaS and WordPress
40
- HIGHLY_CONF = "Sorry, You are already at highest configuration."
41
- LOW_CONF = "Sorry, You are already at lowest configuration."
41
+ HIGHLY_CONF = "You are already at highest configuration."
42
+ LOW_CONF = "You are already at lowest configuration."
42
43
  end
@@ -56,7 +56,10 @@ module App42
56
56
  'startwordpress',
57
57
  'stopwordpress',
58
58
  'wordpresssetups',
59
- 'wordpressinfo'
59
+ 'wordpressinfo',
60
+ 'addcustomurl',
61
+ 'removecustomurl',
62
+ 'customurlinfo'
60
63
  ]
61
64
 
62
65
  end
@@ -1,4 +1,5 @@
1
1
  require "interact"
2
+ require 'uri'
2
3
  require "ipaddress"
3
4
 
4
5
  module App42
@@ -297,6 +298,19 @@ module App42
297
298
  end
298
299
  end
299
300
 
301
+ # Check whether +URL+ is valid OR not
302
+ # +URL+ should start with +http+ and +https+
303
+ # And should not contain any special character
304
+ def validate_url url
305
+ # Using the URI module distributed with Ruby, We can write own URL_REGEX(defined in constant.rb) too.
306
+ unless url =~ /^#{URI::regexp}$/
307
+ message "The provided URL (#{url}) is either not valid or contains white space and special character.", true, 'red'
308
+ return false
309
+ else
310
+ return url
311
+ end
312
+ end
313
+
300
314
  # Check whether +uploadbackup+ path is valid OR not
301
315
  # predefined extension are allowed only like .sql, .zip, .dump etc
302
316
  def validate_upload_backup_path path
@@ -244,6 +244,42 @@ module App42
244
244
  puts table
245
245
  end
246
246
 
247
+ # Add custom URL to app
248
+ def add_custom_url
249
+ @options[:name] = get_app_name if @options[:name].nil?
250
+ custom_url = get_custom_url if is_app_exist? @options[:name]
251
+ costom_url_res = costom_url_operation "addcustomurl", @options[:name], custom_url
252
+ exit! if costom_url_res
253
+ end
254
+
255
+ # Remove custom URL of app
256
+ def remove_custom_url
257
+ @options[:name] = get_app_name if @options[:name].nil?
258
+ custom_url = get_custom_url if is_app_exist? @options[:name]
259
+ costom_url_res = costom_url_operation "removecustomurl", @options[:name], custom_url
260
+ exit! if costom_url_res
261
+ end
262
+
263
+ # List all custom urls of apps
264
+ def urls
265
+ @options[:name] = get_app_name if @options[:name].nil?
266
+
267
+ rows, rows_header_final, rows_header = [], [], nil
268
+ custom_url_info = custom_url_information @options[:name]
269
+ if custom_url_info && custom_url_info['urls']
270
+ custom_url_info['urls'].each do |e|
271
+ rows_header = e.keys
272
+ rows << e.values
273
+ end
274
+
275
+ rows_header.map { |e| rows_header_final << camel_case_to_whitespace(e) }
276
+
277
+ table = Terminal::Table.new :title => Paint["=== #{@options[:name]} Custome URLs Details ===", :green], :headings => rows_header_final, :rows => rows
278
+ puts table
279
+ end
280
+
281
+ end
282
+
247
283
  end
248
284
  end
249
285
  end
@@ -90,6 +90,13 @@ module App42
90
90
  valid_app_name ? (return valid_app_name) : get_app_name
91
91
  end
92
92
 
93
+ # Ask custom URL from user and validate
94
+ def get_custom_url
95
+ url = input "Enter Custom URL", [], true
96
+ valid_url = validate_url url.strip
97
+ valid_url ? (return valid_url) : get_custom_url
98
+ end
99
+
93
100
  # Ask wordpress name from user and
94
101
  # will wait for user response (user will enter wordpress name)
95
102
  def get_wordpress_name
@@ -743,6 +750,49 @@ module App42
743
750
  end
744
751
  end
745
752
 
753
+ # Custom operation will take placed like add, remove etc.
754
+ # expect +what+ as operation, +app_name+ as application name and +url+ custom url.
755
+ def costom_url_operation what, app_name, url
756
+ begin
757
+ if what.to_s == 'addcustomurl'
758
+ response = with_progress(Paint[ "Adding Custom URL To Application #{app_name}", :yellow]) do |s|
759
+ body = {'app42' => {"request"=> {
760
+ "appName" => app_name,
761
+ "url" => url
762
+ }}}.to_json
763
+ query_params = params
764
+ query_params.store('body', body)
765
+ build_post_request body, query_params, "app", "customurl"
766
+ end
767
+ else
768
+ response = with_progress(Paint[ "Removing Custom URL", :yellow]) do |s|
769
+ query_params = params
770
+ query_params.store('appName', app_name)
771
+ query_params.store('url', url)
772
+ build_delete_request query_params, "app", "customurl"
773
+ end
774
+ end
775
+
776
+ response['success'] ? (print Paint["#{response['message']}\n", :green]) : (message "#{response['message']}", true, 'red')
777
+ rescue Interrupt
778
+ puts Paint[" Command cancelled.", :red]
779
+ exit!
780
+ end
781
+ end
782
+
783
+ # Get custom URL details
784
+ def custom_url_information app_name
785
+ query_params = params
786
+ query_params.store('appName', app_name)
787
+ begin
788
+ response = build_get_request query_params, "app/customurl", nil
789
+ rescue Exception => e
790
+ puts e
791
+ exit!
792
+ end
793
+ return response
794
+ end
795
+
746
796
  # create service and get all relevant service information post service creation.
747
797
  #
748
798
  # ==== Parameters
@@ -286,7 +286,16 @@ module App42
286
286
  set_cmd(:wordpress, :wordpresssetups)
287
287
 
288
288
  when 'wordpressinfo'
289
- set_cmd(:wordpress, :info)
289
+ set_cmd(:wordpress, :info)
290
+
291
+ when 'addcustomurl'
292
+ set_cmd(:app, :add_custom_url)
293
+
294
+ when 'removecustomurl'
295
+ set_cmd(:app, :remove_custom_url)
296
+
297
+ when 'customurlinfo'
298
+ set_cmd(:app, :urls)
290
299
 
291
300
  else
292
301
  puts Paint["app42: Unknown command [#{action}]", :red]
@@ -3,7 +3,7 @@ module App42
3
3
  module VERSION
4
4
  MAJOR = 0
5
5
  MINOR = 6
6
- TINY = 0
6
+ TINY = 1
7
7
  PRE = "alpha"
8
8
 
9
9
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app42
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ShepHertz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler