stormmq-client 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #--
4
+ # Copyright (c) 2010, Tony Byrne & StormMQ Ltd.
5
+ # All rights reserved.
6
+ #
7
+ # Please refer to the LICENSE file that accompanies this source
8
+ # for terms of use and redistribution.
9
+ #++
10
+
11
+ $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), "..", "lib")
12
+
13
+ require 'stormmq/application'
14
+
15
+ class StormMQ::Application::DeleteSystem < StormMQ::Application
16
+
17
+ def initialize
18
+ synopsis "--help | <userName> | <userName> <systemName> | <userName> <systemName> <companyName>"
19
+ options :help
20
+ expected_args [1,3]
21
+ end
22
+
23
+ def main
24
+ user = argv[0]
25
+ system = argv[1] || user
26
+ company = argv[2] || user
27
+ self.rest_client(user).delete_system(company, system)
28
+ end
29
+
30
+ def man
31
+ <<-EOM
32
+ NAME
33
+
34
+ #{File.basename(__FILE__)}
35
+
36
+ PURPOSE
37
+
38
+ Deletes systems PERMANENTLY, with no chance of recovery. You can
39
+ recreate the system, of course, if you kept your settings.
40
+ You will just lose any messages in the meantime.
41
+
42
+ USAGE
43
+
44
+ #{File.basename(__FILE__)} --help
45
+ #{File.basename(__FILE__)} <userName>
46
+ #{File.basename(__FILE__)} <userName> <systemName>
47
+ #{File.basename(__FILE__)} <userName> <systemName> <companyName>
48
+
49
+ The second form assumes your companyName and systemName is the same
50
+ as your userName. This is true for ordinary users who've just
51
+ signed up.
52
+
53
+ The third form assumes your companyName is the same as your
54
+ userName. This is true for ordinary users.
55
+
56
+ PARAMETERS
57
+
58
+ <userName>
59
+
60
+ The user name you log into the site with.
61
+
62
+ <systemName>
63
+
64
+ If you're not sure if you've already created a system, use:
65
+
66
+ stormmq-list-systems <userName>
67
+
68
+ A systemName can not contain a '/' or ':'
69
+
70
+ <companyName>
71
+
72
+ For ordinary users, this is the same as your userName. If you're
73
+ not sure of your companyName, you can retrieve it with:
74
+
75
+ stormmq-list-companies <userName>
76
+
77
+ --help, -h
78
+
79
+ Displays this help page then quits.
80
+
81
+ RESULT
82
+
83
+ Outputs nothing.
84
+
85
+ REST API
86
+
87
+ Equivalent is DELETE /companies/<companyName>/<systemName>.
88
+
89
+ NOTES
90
+
91
+ To find you companyName, use:
92
+
93
+ stormmq-list-companies
94
+
95
+ To delete your default system, use:
96
+
97
+ stormmq-delete-system <userName>
98
+
99
+ To create a new system, use:
100
+
101
+ stormmq-create-system <userName> <systemName>
102
+
103
+ COPYRIGHT
104
+
105
+ Copyright (c) 2010, Tony Byrne & StormMQ Ltd.
106
+ All rights reserved.
107
+
108
+ SELF TEST
109
+
110
+ #{self_test}
111
+
112
+ EOM
113
+ end
114
+
115
+ end
116
+
117
+ StormMQ::Application::DeleteSystem.run
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #--
4
+ # Copyright (c) 2010, Tony Byrne & StormMQ Ltd.
5
+ # All rights reserved.
6
+ #
7
+ # Please refer to the LICENSE file that accompanies this source
8
+ # for terms of use and redistribution.
9
+ #++
10
+
11
+ $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), "..", "lib")
12
+
13
+ require 'stormmq/application'
14
+ require 'json'
15
+
16
+ class StormMQ::Application::DescribeCompany < StormMQ::Application
17
+
18
+ def initialize
19
+ synopsis "--help | <userName>"
20
+ options :help
21
+ expected_args [1,2]
22
+ end
23
+
24
+ def main
25
+ user = argv[0]
26
+ company = argv[1] || user
27
+ puts JSON.pretty_generate(self.rest_client(user).describe_company(company))
28
+ end
29
+
30
+ def man
31
+ <<-EOM
32
+ NAME
33
+
34
+ #{File.basename(__FILE__)}
35
+
36
+ PURPOSE
37
+
38
+ Describes all the details we have for your company, including every
39
+ single connection you've made to our Messaging Cloud, how much
40
+ bandwidth you've used, your current account credits and debits and
41
+ invoice contact details. Some of the details of this API are in
42
+ flux. We'd like your feedback in the forums on how to improve it!
43
+
44
+ USAGE
45
+
46
+ #{File.basename(__FILE__)} --help
47
+ #{File.basename(__FILE__)} <userName>
48
+ #{File.basename(__FILE__)} <userName> <companyName>
49
+
50
+ The second form assumes your companyName is the same as your
51
+ userName. This is true for ordinary users.
52
+
53
+ PARAMETERS
54
+
55
+ <userName>
56
+
57
+ The user name you log into the site with.
58
+
59
+ <companyName>
60
+
61
+ For ordinary users, this is the same as your userName. If you're
62
+ not sure of your companyName, you can retrieve it with:
63
+
64
+ stormmq-list-companies <userName>
65
+
66
+ --help, -h
67
+
68
+ Displays this help page then quits.
69
+
70
+ RESULT
71
+
72
+ Outputs a simple JSON list of strings to STDOUT.
73
+
74
+ REST API
75
+
76
+ Equivalent is GET /companies/<companyName>/.
77
+
78
+ NOTES
79
+
80
+ To find you companyName, use:
81
+
82
+ stormmq-list-companies
83
+
84
+ To delete your default system, use:
85
+
86
+ stormmq-delete-system <userName>
87
+
88
+ To create a new system, use:
89
+
90
+ stormmq-create-system <userName> <systemName>
91
+
92
+ COPYRIGHT
93
+
94
+ Copyright (c) 2010, Tony Byrne & StormMQ Ltd.
95
+ All rights reserved.
96
+
97
+ SELF TEST
98
+
99
+ #{self_test}
100
+
101
+ EOM
102
+ end
103
+
104
+ end
105
+
106
+ StormMQ::Application::DescribeCompany.run
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #--
4
+ # Copyright (c) 2010, Tony Byrne & StormMQ Ltd.
5
+ # All rights reserved.
6
+ #
7
+ # Please refer to the LICENSE file that accompanies this source
8
+ # for terms of use and redistribution.
9
+ #++
10
+
11
+ $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), "..", "lib")
12
+
13
+ require 'stormmq/application'
14
+ require 'json'
15
+
16
+ class StormMQ::Application::DescribeSystem < StormMQ::Application
17
+
18
+ def initialize
19
+ synopsis "--help | <userName> | <userName> <systemName> | <userName> <systemName> <companyName>"
20
+ options :help
21
+ expected_args [1,3]
22
+ end
23
+
24
+ def main
25
+ user = argv[0]
26
+ system = argv[1] || user
27
+ company = argv[2] || user
28
+ puts JSON.pretty_generate(self.rest_client(user).describe_system(company, system))
29
+ end
30
+
31
+ def man
32
+ <<-EOM
33
+ NAME
34
+
35
+ #{File.basename(__FILE__)}
36
+
37
+ PURPOSE
38
+
39
+ A system is a logical view of resources in our Messaging Cloud.
40
+ Typically you'd only need one system, eg 'AccountRocks',
41
+ 'InflationSwapCalculator', 'Jibbit-X', etc. A system has
42
+ environments.
43
+
44
+ A company-system-environment triplet matches an AMQP Virtual Host.
45
+ E.g., if your company is widgetcorp, your system is accountrock and
46
+ you want to use an environment of development, your AMQP virtual
47
+ host name is widgetcorp/accountrock/development.
48
+
49
+ If you've just signed up as an ordinary user, then we've already
50
+ created a system called <userName>for you (see stormmq-list-systems),
51
+ with an AMQP virtual host called /<userName>/<userName>/development,
52
+ accessible at amqp.stormmq.com.
53
+
54
+ All AMQP virtual hosts are virtually hosted on amqp.stormmq.com.
55
+
56
+ To find the passwords to log onto them with AMQP, use:
57
+
58
+ stormmq-get-amqpuser-password
59
+
60
+ USAGE
61
+
62
+ #{File.basename(__FILE__)} --help
63
+ #{File.basename(__FILE__)} <userName>
64
+ #{File.basename(__FILE__)} <userName> <systemName>
65
+ #{File.basename(__FILE__)} <userName> <systemName> <companyName>
66
+
67
+ The second form assumes your companyName and systemName is the same
68
+ as your userName. This is true for ordinary users who've just
69
+ signed up.
70
+
71
+ The third form assumes your companyName is the same as your
72
+ userName. This is true for ordinary users.
73
+
74
+ PARAMETERS
75
+
76
+ <userName>
77
+
78
+ The user name you log into the site with.
79
+
80
+ <systemName>
81
+
82
+ If you're not sure if you've already created a system, use:
83
+
84
+ stormmq-list-systems <userName>
85
+
86
+ A systemName can not contain a '/' or ':'
87
+
88
+ <companyName>
89
+
90
+ For ordinary users, this is the same as your userName. If you're
91
+ not sure of your companyName, you can retrieve it with:
92
+
93
+ stormmq-list-companies <userName>
94
+
95
+ --help, -h
96
+
97
+ Displays this help page then quits.
98
+
99
+ RESULT
100
+
101
+ Outputs a pretty-printed complex JSON list to standard out.
102
+
103
+ REST API
104
+
105
+ Equivalent is GET /companies/<companyName>/<systemName>.
106
+
107
+ NOTES
108
+
109
+ To find you companyName, use:
110
+
111
+ stormmq-list-companies
112
+
113
+ To delete your default system, use:
114
+
115
+ stormmq-delete-system <userName>
116
+
117
+ To create a new system, use:
118
+
119
+ stormmq-create-system <userName> <systemName>
120
+
121
+ COPYRIGHT
122
+
123
+ Copyright (c) 2010, Tony Byrne & StormMQ Ltd.
124
+ All rights reserved.
125
+
126
+ SELF TEST
127
+
128
+ #{self_test}
129
+
130
+ EOM
131
+ end
132
+
133
+ end
134
+
135
+ StormMQ::Application::DescribeSystem.run
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #--
4
+ # Copyright (c) 2010, Tony Byrne & StormMQ Ltd.
5
+ # All rights reserved.
6
+ #
7
+ # Please refer to the LICENSE file that accompanies this source
8
+ # for terms of use and redistribution.
9
+ #++
10
+
11
+ $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), "..", "lib")
12
+
13
+ require 'stormmq/application'
14
+
15
+ class StormMQ::Application::GetAMQPUserPassword < StormMQ::Application
16
+
17
+ def initialize
18
+ synopsis "--help | <userName> <systemName> <companyName> <environmentName> <amqpUserName>"
19
+ options :help
20
+ expected_args :user, :system, :company, :environment, :amqp_user
21
+ end
22
+
23
+ def main
24
+ puts self.rest_client(@user).amqp_password(@company, @system, @environment, @amqp_user)
25
+ end
26
+
27
+ def man
28
+ <<-EOM
29
+ NAME
30
+
31
+ #{File.basename(__FILE__)}
32
+
33
+ PURPOSE
34
+
35
+ Gets the password for a given AMQP user name. For a recently signed
36
+ up user, we've created you a default system with a default AMQP
37
+ user name (amqpUserName) the same as your userName. This is the
38
+ only tool you'll need initially.
39
+
40
+ USAGE
41
+
42
+ #{File.basename(__FILE__)} --help
43
+ #{File.basename(__FILE__)} <userName> <systemName> <companyName> <environmentName> <amqpUserName>
44
+
45
+ For ordinary users, your companyName is the same as your userName.
46
+
47
+ For recently signed up users, the systemName is the same as your
48
+ userName.
49
+
50
+ For recently signed up users, the environmentName is one of:
51
+
52
+ * development
53
+ * testing
54
+ * production
55
+
56
+ For recently signed up users, the amqpUserName is the same as your
57
+ userName.
58
+
59
+ PARAMETERS
60
+
61
+ <userName>
62
+
63
+ The user name you log into the site with.
64
+
65
+ <systemName>
66
+
67
+ If you're not sure if you've already created a system, use:
68
+
69
+ stormmq-list-systems <userName>
70
+
71
+ A systemName can not contain a '/' or ':'
72
+
73
+ <companyName>
74
+
75
+ For ordinary users, this is the same as your userName.
76
+ If you're not sure of your companyName, you can retrieve it with:
77
+
78
+ stormmq-list-companies <userName>
79
+
80
+ <environmentName>
81
+
82
+ One of:
83
+
84
+ * development
85
+ * testing
86
+ * production
87
+
88
+ For the default system created when you signed up, or for any
89
+ system created by stormmq-create-system <userName>
90
+ (except advanced use).
91
+
92
+ <amqpUserName>
93
+
94
+ This is your userName for the default system we created when you
95
+ signed up, or for any system created by
96
+ stormmq-create-system <userName> (except advanced use).
97
+
98
+ --help, -h
99
+
100
+ Displays this help page then quits.
101
+
102
+ RESULT
103
+
104
+ Outputs a simple JSON object of string keys (user names to use with
105
+ AMQP) to string values (AMQP passwords, to be used as is without
106
+ decoding but excluding the quotes).
107
+
108
+ If using the default system created when you signed up, then the user
109
+ name to log on to AMQP ('amqpUserName') will be the same as your
110
+ userName.
111
+
112
+ REST API
113
+
114
+ Equivalent is GET /companies/<companyName>/<systemName>/<environmentName>/users/.
115
+
116
+ NOTES
117
+
118
+ Pretty prints JSON, so not suitable for use with XHTML, etc, response
119
+ documents.
120
+
121
+ To find you companyName, use:
122
+
123
+ stormmq-list-companies
124
+
125
+ To delete your default system, use:
126
+
127
+ stormmq-delete-system <userName>
128
+
129
+ To create a new system, use:
130
+
131
+ stormmq-create-system <userName> <systemName>
132
+
133
+ COPYRIGHT
134
+
135
+ Copyright (c) 2010, Tony Byrne & StormMQ Ltd.
136
+ All rights reserved.
137
+
138
+ SELF TEST
139
+
140
+ #{self_test}
141
+
142
+ EOM
143
+ end
144
+
145
+
146
+ end
147
+
148
+ StormMQ::Application::GetAMQPUserPassword.run