zeus-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.1"
12
+ gem "rcov", ">= 0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.5.1)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.8.7)
10
+ rcov (0.9.9)
11
+ shoulda (2.11.3)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jeweler (~> 1.5.1)
19
+ rcov
20
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 David Peterson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,18 @@
1
+ = zeus-api
2
+
3
+ Ruby control API for Zeus Load Balancer and Zeus Traffic Manager.
4
+
5
+ == Contributing to zeus-api
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 David Peterson. See LICENSE.txt for further details.
18
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "zeus-api"
16
+ gem.homepage = "http://github.com/peterson/zeus-api"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Ruby control API for Zeus Load Balancer and Zeus Traffic Manager}
19
+ gem.description = %Q{This gem implements a wrapper to the SOAP control API provided by Zeus Load Balance (ZLB) and Zeus Traffic Manager (ZTM).}
20
+ gem.email = "peterson@orbitec.com.au"
21
+ gem.authors = ["David Peterson"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ gem.add_runtime_dependency 'soap4r', '>= 1.5.8'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "zeus-api #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,62 @@
1
+ require 'xsd/qname'
2
+
3
+ # {http://soap.zeus.com/zxtm/1.0/}Catalog.Rule.RuleInfo
4
+ # rule_text - SOAP::SOAPString
5
+ # rule_notes - SOAP::SOAPString
6
+ class CatalogRuleRuleInfo
7
+ attr_accessor :rule_text
8
+ attr_accessor :rule_notes
9
+
10
+ def initialize(rule_text = nil, rule_notes = nil)
11
+ @rule_text = rule_text
12
+ @rule_notes = rule_notes
13
+ end
14
+ end
15
+
16
+ # {http://soap.zeus.com/zxtm/1.0/}Catalog.Rule.SyntaxCheck
17
+ # valid - SOAP::SOAPBoolean
18
+ # warnings - SOAP::SOAPString
19
+ # errors - SOAP::SOAPString
20
+ class CatalogRuleSyntaxCheck
21
+ attr_accessor :valid
22
+ attr_accessor :warnings
23
+ attr_accessor :errors
24
+
25
+ def initialize(valid = nil, warnings = nil, errors = nil)
26
+ @valid = valid
27
+ @warnings = warnings
28
+ @errors = errors
29
+ end
30
+ end
31
+
32
+ # {http://soap.zeus.com/zxtm/1.0/}Catalog.Rule.RuleInfoArray
33
+ class CatalogRuleRuleInfoArray < ::Array
34
+ end
35
+
36
+ # {http://soap.zeus.com/zxtm/1.0/}Catalog.Rule.SyntaxCheckArray
37
+ class CatalogRuleSyntaxCheckArray < ::Array
38
+ end
39
+
40
+ # {http://soap.zeus.com/zxtm/1.0/}StringArray
41
+ class StringArray < ::Array
42
+ end
43
+
44
+ # {http://soap.zeus.com/zxtm/1.0/}StringArrayArray
45
+ class StringArrayArray < ::Array
46
+ end
47
+
48
+ # {http://soap.zeus.com/zxtm/1.0/}booleanArray
49
+ class BooleanArray < ::Array
50
+ end
51
+
52
+ # {http://soap.zeus.com/zxtm/1.0/}booleanArrayArray
53
+ class BooleanArrayArray < ::Array
54
+ end
55
+
56
+ # {http://soap.zeus.com/zxtm/1.0/}intArray
57
+ class IntArray < ::Array
58
+ end
59
+
60
+ # {http://soap.zeus.com/zxtm/1.0/}unsignedIntArray
61
+ class UnsignedIntArray < ::Array
62
+ end
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env ruby
2
+ require 'CatalogRuleDriver.rb'
3
+
4
+ endpoint_url = ARGV.shift
5
+ obj = CatalogRulePort.new(endpoint_url)
6
+
7
+ # run ruby with -d to see SOAP wiredumps.
8
+ obj.wiredump_dev = STDERR if $DEBUG
9
+
10
+ # SYNOPSIS
11
+ # addRule(names, texts)
12
+ #
13
+ # ARGS
14
+ # names StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
15
+ # texts StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
16
+ #
17
+ # RETURNS
18
+ # N/A
19
+ #
20
+ names = texts = nil
21
+ puts obj.addRule(names, texts)
22
+
23
+ # SYNOPSIS
24
+ # checkSyntax(rule_text)
25
+ #
26
+ # ARGS
27
+ # rule_text StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
28
+ #
29
+ # RETURNS
30
+ # results CatalogRuleSyntaxCheckArray - {http://soap.zeus.com/zxtm/1.0/}Catalog.Rule.SyntaxCheckArray
31
+ #
32
+ rule_text = nil
33
+ puts obj.checkSyntax(rule_text)
34
+
35
+ # SYNOPSIS
36
+ # copyRule(names, new_names)
37
+ #
38
+ # ARGS
39
+ # names StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
40
+ # new_names StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
41
+ #
42
+ # RETURNS
43
+ # N/A
44
+ #
45
+ names = new_names = nil
46
+ puts obj.copyRule(names, new_names)
47
+
48
+ # SYNOPSIS
49
+ # deleteRule(names)
50
+ #
51
+ # ARGS
52
+ # names StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
53
+ #
54
+ # RETURNS
55
+ # N/A
56
+ #
57
+ names = nil
58
+ puts obj.deleteRule(names)
59
+
60
+ # SYNOPSIS
61
+ # getRuleDetails(names)
62
+ #
63
+ # ARGS
64
+ # names StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
65
+ #
66
+ # RETURNS
67
+ # info CatalogRuleRuleInfoArray - {http://soap.zeus.com/zxtm/1.0/}Catalog.Rule.RuleInfoArray
68
+ #
69
+ names = nil
70
+ puts obj.getRuleDetails(names)
71
+
72
+ # SYNOPSIS
73
+ # getRuleNames
74
+ #
75
+ # ARGS
76
+ # N/A
77
+ #
78
+ # RETURNS
79
+ # names StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
80
+ #
81
+
82
+ puts obj.getRuleNames
83
+
84
+ # SYNOPSIS
85
+ # renameRule(names, new_names)
86
+ #
87
+ # ARGS
88
+ # names StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
89
+ # new_names StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
90
+ #
91
+ # RETURNS
92
+ # N/A
93
+ #
94
+ names = new_names = nil
95
+ puts obj.renameRule(names, new_names)
96
+
97
+ # SYNOPSIS
98
+ # setRuleNotes(names, notes)
99
+ #
100
+ # ARGS
101
+ # names StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
102
+ # notes StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
103
+ #
104
+ # RETURNS
105
+ # N/A
106
+ #
107
+ names = notes = nil
108
+ puts obj.setRuleNotes(names, notes)
109
+
110
+ # SYNOPSIS
111
+ # setRuleText(names, text)
112
+ #
113
+ # ARGS
114
+ # names StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
115
+ # text StringArray - {http://soap.zeus.com/zxtm/1.0/}StringArray
116
+ #
117
+ # RETURNS
118
+ # N/A
119
+ #
120
+ names = text = nil
121
+ puts obj.setRuleText(names, text)
122
+
123
+
@@ -0,0 +1,117 @@
1
+ require 'soap/rpc/driver'
2
+
3
+ class CatalogRulePort < ::SOAP::RPC::Driver
4
+ DefaultEndpointUrl = "https://admin_server:9090/soap"
5
+ NsRule = "http://soap.zeus.com/zxtm/1.0/Catalog/Rule/"
6
+
7
+ Methods = [
8
+ [ XSD::QName.new(NsRule, "addRule"),
9
+ "http://soap.zeus.com/zxtm/1.0/Catalog/Rule/addRule",
10
+ "addRule",
11
+ [ ["in", "names", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]],
12
+ ["in", "texts", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]] ],
13
+ { :request_style => :rpc, :request_use => :encoded,
14
+ :response_style => :rpc, :response_use => :encoded,
15
+ :faults => {} }
16
+ ],
17
+ [ XSD::QName.new(NsRule, "checkSyntax"),
18
+ "http://soap.zeus.com/zxtm/1.0/Catalog/Rule/checkSyntax",
19
+ "checkSyntax",
20
+ [ ["in", "rule_text", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]],
21
+ ["retval", "results", ["CatalogRuleSyntaxCheckArray", "http://soap.zeus.com/zxtm/1.0/", "Catalog.Rule.SyntaxCheckArray"]] ],
22
+ { :request_style => :rpc, :request_use => :encoded,
23
+ :response_style => :rpc, :response_use => :encoded,
24
+ :faults => {} }
25
+ ],
26
+ [ XSD::QName.new(NsRule, "copyRule"),
27
+ "http://soap.zeus.com/zxtm/1.0/Catalog/Rule/copyRule",
28
+ "copyRule",
29
+ [ ["in", "names", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]],
30
+ ["in", "new_names", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]] ],
31
+ { :request_style => :rpc, :request_use => :encoded,
32
+ :response_style => :rpc, :response_use => :encoded,
33
+ :faults => {} }
34
+ ],
35
+ [ XSD::QName.new(NsRule, "deleteRule"),
36
+ "http://soap.zeus.com/zxtm/1.0/Catalog/Rule/deleteRule",
37
+ "deleteRule",
38
+ [ ["in", "names", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]] ],
39
+ { :request_style => :rpc, :request_use => :encoded,
40
+ :response_style => :rpc, :response_use => :encoded,
41
+ :faults => {} }
42
+ ],
43
+ [ XSD::QName.new(NsRule, "getRuleDetails"),
44
+ "http://soap.zeus.com/zxtm/1.0/Catalog/Rule/getRuleDetails",
45
+ "getRuleDetails",
46
+ [ ["in", "names", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]],
47
+ ["retval", "info", ["CatalogRuleRuleInfoArray", "http://soap.zeus.com/zxtm/1.0/", "Catalog.Rule.RuleInfoArray"]] ],
48
+ { :request_style => :rpc, :request_use => :encoded,
49
+ :response_style => :rpc, :response_use => :encoded,
50
+ :faults => {} }
51
+ ],
52
+ [ XSD::QName.new(NsRule, "getRuleNames"),
53
+ "http://soap.zeus.com/zxtm/1.0/Catalog/Rule/getRuleNames",
54
+ "getRuleNames",
55
+ [ ["retval", "names", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]] ],
56
+ { :request_style => :rpc, :request_use => :encoded,
57
+ :response_style => :rpc, :response_use => :encoded,
58
+ :faults => {} }
59
+ ],
60
+ [ XSD::QName.new(NsRule, "renameRule"),
61
+ "http://soap.zeus.com/zxtm/1.0/Catalog/Rule/renameRule",
62
+ "renameRule",
63
+ [ ["in", "names", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]],
64
+ ["in", "new_names", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]] ],
65
+ { :request_style => :rpc, :request_use => :encoded,
66
+ :response_style => :rpc, :response_use => :encoded,
67
+ :faults => {} }
68
+ ],
69
+ [ XSD::QName.new(NsRule, "setRuleNotes"),
70
+ "http://soap.zeus.com/zxtm/1.0/Catalog/Rule/setRuleNotes",
71
+ "setRuleNotes",
72
+ [ ["in", "names", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]],
73
+ ["in", "notes", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]] ],
74
+ { :request_style => :rpc, :request_use => :encoded,
75
+ :response_style => :rpc, :response_use => :encoded,
76
+ :faults => {} }
77
+ ],
78
+ [ XSD::QName.new(NsRule, "setRuleText"),
79
+ "http://soap.zeus.com/zxtm/1.0/Catalog/Rule/setRuleText",
80
+ "setRuleText",
81
+ [ ["in", "names", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]],
82
+ ["in", "text", ["StringArray", "http://soap.zeus.com/zxtm/1.0/", "StringArray"]] ],
83
+ { :request_style => :rpc, :request_use => :encoded,
84
+ :response_style => :rpc, :response_use => :encoded,
85
+ :faults => {} }
86
+ ]
87
+ ]
88
+
89
+ def initialize(endpoint_url = nil)
90
+ endpoint_url ||= DefaultEndpointUrl
91
+ super(endpoint_url, nil)
92
+ self.mapping_registry = CatalogRuleMappingRegistry::EncodedRegistry
93
+ self.literal_mapping_registry = CatalogRuleMappingRegistry::LiteralRegistry
94
+ init_methods
95
+ end
96
+
97
+ private
98
+
99
+ def init_methods
100
+ Methods.each do |definitions|
101
+ opt = definitions.last
102
+ if opt[:request_style] == :document
103
+ add_document_operation(*definitions)
104
+ else
105
+ add_rpc_operation(*definitions)
106
+ qname = definitions[0]
107
+ name = definitions[2]
108
+ if qname.name != name and qname.name.capitalize == name.capitalize
109
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
110
+ __send__(name, *arg)
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+