blueprint_ruby_client 0.1.0

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.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +65 -0
  4. data/README.md +152 -0
  5. data/blueprint_ruby_client.gemspec +31 -0
  6. data/config.json +13 -0
  7. data/docs/Asset.md +9 -0
  8. data/docs/AssetBody.md +9 -0
  9. data/docs/AssetResultSet.md +9 -0
  10. data/docs/AssetsApi.md +376 -0
  11. data/docs/Error.md +10 -0
  12. data/docs/Errors.md +8 -0
  13. data/docs/HierarchyApi.md +745 -0
  14. data/docs/Links.md +10 -0
  15. data/docs/Meta.md +10 -0
  16. data/docs/Namespace.md +9 -0
  17. data/docs/NamespaceRelationship.md +8 -0
  18. data/docs/Node.md +11 -0
  19. data/docs/NodeAttributes.md +13 -0
  20. data/docs/NodeBody.md +9 -0
  21. data/docs/NodeRelationship.md +10 -0
  22. data/docs/NodeRelationships.md +10 -0
  23. data/docs/NodeResultSet.md +10 -0
  24. data/generate.sh +7 -0
  25. data/git_push.sh +52 -0
  26. data/lib/blueprint_ruby_client/api/assets_api.rb +598 -0
  27. data/lib/blueprint_ruby_client/api/hierarchy_api.rb +1174 -0
  28. data/lib/blueprint_ruby_client/api_client.rb +365 -0
  29. data/lib/blueprint_ruby_client/api_error.rb +36 -0
  30. data/lib/blueprint_ruby_client/configuration.rb +170 -0
  31. data/lib/blueprint_ruby_client/models/asset.rb +242 -0
  32. data/lib/blueprint_ruby_client/models/asset_body.rb +237 -0
  33. data/lib/blueprint_ruby_client/models/asset_result_set.rb +234 -0
  34. data/lib/blueprint_ruby_client/models/error.rb +267 -0
  35. data/lib/blueprint_ruby_client/models/errors.rb +209 -0
  36. data/lib/blueprint_ruby_client/models/links.rb +257 -0
  37. data/lib/blueprint_ruby_client/models/meta.rb +260 -0
  38. data/lib/blueprint_ruby_client/models/namespace.rb +242 -0
  39. data/lib/blueprint_ruby_client/models/namespace_relationship.rb +207 -0
  40. data/lib/blueprint_ruby_client/models/node.rb +293 -0
  41. data/lib/blueprint_ruby_client/models/node_attributes.rb +338 -0
  42. data/lib/blueprint_ruby_client/models/node_body.rb +237 -0
  43. data/lib/blueprint_ruby_client/models/node_relationship.rb +259 -0
  44. data/lib/blueprint_ruby_client/models/node_relationships.rb +257 -0
  45. data/lib/blueprint_ruby_client/models/node_result_set.rb +261 -0
  46. data/lib/blueprint_ruby_client/version.rb +15 -0
  47. data/lib/blueprint_ruby_client.rb +56 -0
  48. data/spec/api/assets_api_spec.rb +150 -0
  49. data/spec/api/hierarchy_api_spec.rb +266 -0
  50. data/spec/models/asset_body_spec.rb +56 -0
  51. data/spec/models/asset_result_set_spec.rb +56 -0
  52. data/spec/models/asset_spec.rb +56 -0
  53. data/spec/models/error_spec.rb +66 -0
  54. data/spec/models/errors_spec.rb +46 -0
  55. data/spec/models/links_spec.rb +66 -0
  56. data/spec/models/meta_spec.rb +66 -0
  57. data/spec/models/namespace_relationship_spec.rb +46 -0
  58. data/spec/models/namespace_spec.rb +56 -0
  59. data/spec/models/node_attributes_spec.rb +96 -0
  60. data/spec/models/node_body_spec.rb +56 -0
  61. data/spec/models/node_relationship_spec.rb +66 -0
  62. data/spec/models/node_relationships_spec.rb +66 -0
  63. data/spec/models/node_result_set_spec.rb +66 -0
  64. data/spec/models/node_spec.rb +76 -0
  65. data/swagger-codegen-cli.jar +0 -0
  66. data/templates/Gemfile.mustache +4 -0
  67. data/templates/README.mustache +139 -0
  68. data/templates/api.mustache +135 -0
  69. data/templates/api_client.mustache +357 -0
  70. data/templates/api_doc.mustache +79 -0
  71. data/templates/api_error.mustache +28 -0
  72. data/templates/api_info.mustache +18 -0
  73. data/templates/api_test.mustache +47 -0
  74. data/templates/base_object.mustache +103 -0
  75. data/templates/configuration.mustache +192 -0
  76. data/templates/gem.mustache +40 -0
  77. data/templates/gemspec.mustache +31 -0
  78. data/templates/gitignore.mustache +40 -0
  79. data/templates/model.mustache +242 -0
  80. data/templates/model_doc.mustache +9 -0
  81. data/templates/model_test.mustache +40 -0
  82. data/templates/version.mustache +7 -0
  83. metadata +322 -0
@@ -0,0 +1,18 @@
1
+ {{#appName}}{{{appName}}}
2
+
3
+ {{/appName}}
4
+ {{#appDescription}}{{{appDescription}}}
5
+
6
+ {{/appDescription}}
7
+ {{#version}}OpenAPI spec version: {{version}}{{/version}}
8
+ {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
9
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
10
+
11
+ {{#licenseInfo}}
12
+ License: {{{licenseInfo}}}
13
+ {{#licenseUrl}}{{licenseUrl}}{{/licenseUrl}}
14
+
15
+ {{/licenseInfo}}
16
+ {{#termsOfService}}
17
+ Terms of Service: {{{termsOfService}}}
18
+ {{/termsOfService}}
@@ -0,0 +1,47 @@
1
+ =begin
2
+ {{> api_info}}
3
+ =end
4
+
5
+ require 'spec_helper'
6
+ require 'json'
7
+
8
+ # Unit tests for {{moduleName}}::{{classname}}
9
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
10
+ # Please update as you see appropriate
11
+ {{#operations}}describe '{{classname}}' do
12
+ before do
13
+ # run before each test
14
+ @instance = {{moduleName}}::{{classname}}.new
15
+ end
16
+
17
+ after do
18
+ # run after each test
19
+ end
20
+
21
+ describe 'test an instance of {{classname}}' do
22
+ it 'should create an instact of {{classname}}' do
23
+ @instance.should be_a({{moduleName}}::{{classname}})
24
+ end
25
+ end
26
+
27
+ {{#operation}}
28
+ # unit tests for {{operationId}}
29
+ # {{summary}}
30
+ # {{notes}}
31
+ {{#allParams}}{{#required}} # @param {{paramName}} {{description}}
32
+ {{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
33
+ {{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
34
+ {{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
35
+ describe '{{operationId}} test' do
36
+ it "should work" do
37
+ # assertion here
38
+ # should be_a()
39
+ # should be_nil
40
+ # should ==
41
+ # should_not ==
42
+ end
43
+ end
44
+
45
+ {{/operation}}
46
+ end
47
+ {{/operations}}
@@ -0,0 +1,103 @@
1
+ # Builds the object from hash
2
+ # @param [Hash] attributes Model attributes in the form of hash
3
+ # @return [Object] Returns the model itself
4
+ def build_from_hash(attributes)
5
+ return nil unless attributes.is_a?(Hash)
6
+ self.class.swagger_types.each_pair do |key, type|
7
+ if type =~ /^Array<(.*)>/i
8
+ # check to ensure the input is an array given that the the attribute
9
+ # is documented as an array but the input is not
10
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
11
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
12
+ end
13
+ elsif !attributes[self.class.attribute_map[key]].nil?
14
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
15
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
16
+ end
17
+
18
+ self
19
+ end
20
+
21
+ # Deserializes the data based on type
22
+ # @param string type Data type
23
+ # @param string value Value to be deserialized
24
+ # @return [Object] Deserialized data
25
+ def _deserialize(type, value)
26
+ case type.to_sym
27
+ when :DateTime
28
+ DateTime.parse(value)
29
+ when :Date
30
+ Date.parse(value)
31
+ when :String
32
+ value.to_s
33
+ when :Integer
34
+ value.to_i
35
+ when :Float
36
+ value.to_f
37
+ when :BOOLEAN
38
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
39
+ true
40
+ else
41
+ false
42
+ end
43
+ when :Object
44
+ # generic object (usually a Hash), return directly
45
+ value
46
+ when /\AArray<(?<inner_type>.+)>\z/
47
+ inner_type = Regexp.last_match[:inner_type]
48
+ value.map { |v| _deserialize(inner_type, v) }
49
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
50
+ k_type = Regexp.last_match[:k_type]
51
+ v_type = Regexp.last_match[:v_type]
52
+ {}.tap do |hash|
53
+ value.each do |k, v|
54
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
55
+ end
56
+ end
57
+ else # model
58
+ temp_model = {{moduleName}}.const_get(type).new
59
+ temp_model.build_from_hash(value)
60
+ end
61
+ end
62
+
63
+ # Returns the string representation of the object
64
+ # @return [String] String presentation of the object
65
+ def to_s
66
+ to_hash.to_s
67
+ end
68
+
69
+ # to_body is an alias to to_hash (backward compatibility)
70
+ # @return [Hash] Returns the object in the form of hash
71
+ def to_body
72
+ to_hash
73
+ end
74
+
75
+ # Returns the object in the form of hash
76
+ # @return [Hash] Returns the object in the form of hash
77
+ def to_hash
78
+ hash = {}
79
+ self.class.attribute_map.each_pair do |attr, param|
80
+ value = self.send(attr)
81
+ next if value.nil?
82
+ hash[param] = _to_hash(value)
83
+ end
84
+ hash
85
+ end
86
+
87
+ # Outputs non-array value in the form of hash
88
+ # For object, use to_hash. Otherwise, just return the value
89
+ # @param [Object] value Any valid value
90
+ # @return [Hash] Returns the value in the form of hash
91
+ def _to_hash(value)
92
+ if value.is_a?(Array)
93
+ value.compact.map{ |v| _to_hash(v) }
94
+ elsif value.is_a?(Hash)
95
+ {}.tap do |hash|
96
+ value.each { |k, v| hash[k] = _to_hash(v) }
97
+ end
98
+ elsif value.respond_to? :to_hash
99
+ value.to_hash
100
+ else
101
+ value
102
+ end
103
+ end
@@ -0,0 +1,192 @@
1
+ require 'uri'
2
+
3
+ module {{moduleName}}
4
+ class Configuration
5
+ # Defines url scheme
6
+ attr_accessor :scheme
7
+
8
+ # Defines url host
9
+ attr_accessor :host
10
+
11
+ # Defines url base path
12
+ attr_accessor :base_path
13
+
14
+ # Defines API keys used with API Key authentications.
15
+ #
16
+ # @return [Hash] key: parameter name, value: parameter value (API key)
17
+ #
18
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
19
+ # config.api_key['api_key'] = 'xxx'
20
+ attr_accessor :api_key
21
+
22
+ # Defines API key prefixes used with API Key authentications.
23
+ #
24
+ # @return [Hash] key: parameter name, value: API key prefix
25
+ #
26
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
27
+ # config.api_key_prefix['api_key'] = 'Token'
28
+ attr_accessor :api_key_prefix
29
+
30
+ # Defines the username used with HTTP basic authentication.
31
+ #
32
+ # @return [String]
33
+ attr_accessor :username
34
+
35
+ # Defines the password used with HTTP basic authentication.
36
+ #
37
+ # @return [String]
38
+ attr_accessor :password
39
+
40
+ # Defines the access token (Bearer) used with OAuth2.
41
+ attr_accessor :access_token
42
+
43
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
44
+ # details will be logged with `logger.debug` (see the `logger` attribute).
45
+ # Default to false.
46
+ #
47
+ # @return [true, false]
48
+ attr_accessor :debugging
49
+
50
+ # Defines the logger used for debugging.
51
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
52
+ #
53
+ # @return [#debug]
54
+ attr_accessor :logger
55
+
56
+ # Defines the temporary folder to store downloaded files
57
+ # (for API endpoints that have file response).
58
+ # Default to use `Tempfile`.
59
+ #
60
+ # @return [String]
61
+ attr_accessor :temp_folder_path
62
+
63
+ # The time limit for HTTP request in seconds.
64
+ # Default to 0 (never times out).
65
+ attr_accessor :timeout
66
+
67
+ ### TLS/SSL
68
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
69
+ # Default to true.
70
+ #
71
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
72
+ #
73
+ # @return [true, false]
74
+ attr_accessor :verify_ssl
75
+
76
+ # Set this to customize the certificate file to verify the peer.
77
+ #
78
+ # @return [String] the path to the certificate file
79
+ #
80
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
81
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
82
+ attr_accessor :ssl_ca_cert
83
+
84
+ # Client certificate file (for client certificate)
85
+ attr_accessor :cert_file
86
+
87
+ # Client private key file (for client certificate)
88
+ attr_accessor :key_file
89
+
90
+ attr_accessor :inject_format
91
+
92
+ attr_accessor :force_ending_format
93
+
94
+ def initialize
95
+ @scheme = '{{scheme}}'
96
+ @host = '{{host}}'
97
+ @base_path = '{{contextPath}}'
98
+ @api_key = {}
99
+ @api_key_prefix = {}
100
+ @timeout = 0
101
+ @verify_ssl = true
102
+ @cert_file = nil
103
+ @key_file = nil
104
+ @debugging = false
105
+ @inject_format = false
106
+ @force_ending_format = false
107
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
108
+
109
+ yield(self) if block_given?
110
+ end
111
+
112
+ # The default Configuration object.
113
+ def self.default
114
+ @@default ||= Configuration.new
115
+ end
116
+
117
+ def configure
118
+ yield(self) if block_given?
119
+ end
120
+
121
+ def scheme=(scheme)
122
+ # remove :// from scheme
123
+ @scheme = scheme.sub(/:\/\//, '')
124
+ end
125
+
126
+ def host=(host)
127
+ # remove http(s):// and anything after a slash
128
+ @host = host.sub(/https?:\/\//, '').split('/').first
129
+ end
130
+
131
+ def base_path=(base_path)
132
+ # Add leading and trailing slashes to base_path
133
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
134
+ @base_path = "" if @base_path == "/"
135
+ end
136
+
137
+ def base_url
138
+ url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
139
+ URI.encode(url)
140
+ end
141
+
142
+ # Gets API key (with prefix if set).
143
+ # @param [String] param_name the parameter name of API key auth
144
+ def api_key_with_prefix(param_name)
145
+ if @api_key_prefix[param_name]
146
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
147
+ else
148
+ @api_key[param_name]
149
+ end
150
+ end
151
+
152
+ # Gets Basic Auth token string
153
+ def basic_auth_token
154
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
155
+ end
156
+
157
+ # Returns Auth Settings hash for api client.
158
+ def auth_settings
159
+ {
160
+ {{#authMethods}}
161
+ {{#isApiKey}}
162
+ '{{name}}' =>
163
+ {
164
+ type: 'api_key',
165
+ in: {{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}},
166
+ key: '{{keyParamName}}',
167
+ value: api_key_with_prefix('{{keyParamName}}')
168
+ },
169
+ {{/isApiKey}}
170
+ {{#isBasic}}
171
+ '{{name}}' =>
172
+ {
173
+ type: 'basic',
174
+ in: 'header',
175
+ key: 'Authorization',
176
+ value: basic_auth_token
177
+ },
178
+ {{/isBasic}}
179
+ {{#isOAuth}}
180
+ '{{name}}' =>
181
+ {
182
+ type: 'oauth2',
183
+ in: 'header',
184
+ key: 'Authorization',
185
+ value: "Bearer #{access_token}"
186
+ },
187
+ {{/isOAuth}}
188
+ {{/authMethods}}
189
+ }
190
+ end
191
+ end
192
+ end
@@ -0,0 +1,40 @@
1
+ =begin
2
+ {{> api_info}}
3
+ =end
4
+
5
+ # Common files
6
+ require '{{gemName}}/api_client'
7
+ require '{{gemName}}/api_error'
8
+ require '{{gemName}}/version'
9
+ require '{{gemName}}/configuration'
10
+
11
+ # Models
12
+ {{#models}}
13
+ {{#model}}
14
+ require '{{gemName}}/{{modelPackage}}/{{classFilename}}'{{/model}}
15
+ {{/models}}
16
+
17
+ # APIs
18
+ {{#apiInfo}}
19
+ {{#apis}}
20
+ require '{{importPath}}'
21
+ {{/apis}}
22
+ {{/apiInfo}}
23
+
24
+ module {{moduleName}}
25
+ class << self
26
+ # Customize default settings for the SDK using block.
27
+ # {{moduleName}}.configure do |config|
28
+ # config.username = "xxx"
29
+ # config.password = "xxx"
30
+ # end
31
+ # If no block given, return the default Configuration object.
32
+ def configure
33
+ if block_given?
34
+ yield(Configuration.default)
35
+ else
36
+ Configuration.default
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "{{gemName}}/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "{{gemName}}{{^gemName}}{{{appName}}}{{/gemName}}"
7
+ s.version = {{moduleName}}::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["{{gemAuthor}}{{^gemAuthor}}Swagger-Codegen{{/gemAuthor}}"]
10
+ s.email = ["{{gemAuthorEmail}}{{^gemAuthorEmail}}{{infoEmail}}{{/gemAuthorEmail}}"]
11
+ s.homepage = "{{gemHomepage}}{{^gemHomepage}}https://github.com/swagger-api/swagger-codegen{{/gemHomepage}}"
12
+ s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}"
13
+ s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}"
14
+ s.license = "{{gemLicense}}{{^gemLicense}}{{{licenseInfo}}}{{^licenseInfo}}Apache 2.0{{/licenseInfo}}{{/gemLicense}}"
15
+
16
+ s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
17
+ s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
18
+
19
+ s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
20
+ s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
21
+ s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
22
+ s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
23
+ s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2'
24
+ s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
25
+ s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.11'
26
+
27
+ s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
28
+ s.test_files = `find spec/*`.split("\n")
29
+ s.executables = []
30
+ s.require_paths = ["lib"]
31
+ end
@@ -0,0 +1,40 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalization:
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ Gemfile.lock
32
+ .ruby-version
33
+ .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
37
+
38
+ # Swagger code generator
39
+ *.jar
40
+ git_push.sh