minecraft_versions 0.10.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 (53) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +72 -0
  4. data/README.md +98 -0
  5. data/Rakefile +10 -0
  6. data/bin/bundle +109 -0
  7. data/bin/byebug +27 -0
  8. data/bin/coderay +27 -0
  9. data/bin/htmldiff +27 -0
  10. data/bin/ldiff +27 -0
  11. data/bin/pry +27 -0
  12. data/bin/racc +27 -0
  13. data/bin/rake +27 -0
  14. data/bin/rspec +27 -0
  15. data/bin/rubocop +27 -0
  16. data/bin/ruby-parse +27 -0
  17. data/bin/ruby-rewrite +27 -0
  18. data/docs/DefaultApi.md +132 -0
  19. data/docs/Download.md +22 -0
  20. data/docs/Version.md +26 -0
  21. data/docs/VersionManifest.md +20 -0
  22. data/docs/VersionManifestLatest.md +20 -0
  23. data/docs/VersionPackageInfo.md +40 -0
  24. data/docs/VersionPackageInfoAssetIndex.md +26 -0
  25. data/docs/VersionPackageInfoDownloads.md +24 -0
  26. data/docs/VersionPackageInfoJavaVersion.md +20 -0
  27. data/git_push.sh +57 -0
  28. data/lib/minecraft_versions/api/default_api.rb +142 -0
  29. data/lib/minecraft_versions/api_client.rb +391 -0
  30. data/lib/minecraft_versions/api_error.rb +56 -0
  31. data/lib/minecraft_versions/configuration.rb +293 -0
  32. data/lib/minecraft_versions/models/download.rb +230 -0
  33. data/lib/minecraft_versions/models/version.rb +248 -0
  34. data/lib/minecraft_versions/models/version_manifest.rb +223 -0
  35. data/lib/minecraft_versions/models/version_manifest_latest.rb +221 -0
  36. data/lib/minecraft_versions/models/version_package_info.rb +311 -0
  37. data/lib/minecraft_versions/models/version_package_info_asset_index.rb +248 -0
  38. data/lib/minecraft_versions/models/version_package_info_downloads.rb +239 -0
  39. data/lib/minecraft_versions/models/version_package_info_java_version.rb +221 -0
  40. data/lib/minecraft_versions/version.rb +13 -0
  41. data/lib/minecraft_versions.rb +46 -0
  42. data/minecraft_versions.gemspec +37 -0
  43. data/spec/api/default_api_spec.rb +55 -0
  44. data/spec/models/download_spec.rb +46 -0
  45. data/spec/models/version_manifest_latest_spec.rb +40 -0
  46. data/spec/models/version_manifest_spec.rb +40 -0
  47. data/spec/models/version_package_info_asset_index_spec.rb +58 -0
  48. data/spec/models/version_package_info_downloads_spec.rb +52 -0
  49. data/spec/models/version_package_info_java_version_spec.rb +40 -0
  50. data/spec/models/version_package_info_spec.rb +100 -0
  51. data/spec/models/version_spec.rb +58 -0
  52. data/spec/spec_helper.rb +109 -0
  53. metadata +144 -0
@@ -0,0 +1,293 @@
1
+ =begin
2
+ #SDK for Minecraft versions info
3
+
4
+ The version of the OpenAPI document: 0.10.0
5
+ Contact: blah+oapicf@cliffano.com
6
+ Generated by: https://openapi-generator.tech
7
+ Generator version: 7.6.0
8
+
9
+ =end
10
+
11
+ module MinecraftVersionsClient
12
+ class Configuration
13
+ # Defines url scheme
14
+ attr_accessor :scheme
15
+
16
+ # Defines url host
17
+ attr_accessor :host
18
+
19
+ # Defines url base path
20
+ attr_accessor :base_path
21
+
22
+ # Define server configuration index
23
+ attr_accessor :server_index
24
+
25
+ # Define server operation configuration index
26
+ attr_accessor :server_operation_index
27
+
28
+ # Default server variables
29
+ attr_accessor :server_variables
30
+
31
+ # Default server operation variables
32
+ attr_accessor :server_operation_variables
33
+
34
+ # Defines API keys used with API Key authentications.
35
+ #
36
+ # @return [Hash] key: parameter name, value: parameter value (API key)
37
+ #
38
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
39
+ # config.api_key['api_key'] = 'xxx'
40
+ attr_accessor :api_key
41
+
42
+ # Defines API key prefixes used with API Key authentications.
43
+ #
44
+ # @return [Hash] key: parameter name, value: API key prefix
45
+ #
46
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
47
+ # config.api_key_prefix['api_key'] = 'Token'
48
+ attr_accessor :api_key_prefix
49
+
50
+ # Defines the username used with HTTP basic authentication.
51
+ #
52
+ # @return [String]
53
+ attr_accessor :username
54
+
55
+ # Defines the password used with HTTP basic authentication.
56
+ #
57
+ # @return [String]
58
+ attr_accessor :password
59
+
60
+ # Defines the access token (Bearer) used with OAuth2.
61
+ attr_accessor :access_token
62
+
63
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
64
+ # Overrides the access_token if set
65
+ # @return [Proc]
66
+ attr_accessor :access_token_getter
67
+
68
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
69
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
70
+ # Default to false.
71
+ attr_accessor :return_binary_data
72
+
73
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
74
+ # details will be logged with `logger.debug` (see the `logger` attribute).
75
+ # Default to false.
76
+ #
77
+ # @return [true, false]
78
+ attr_accessor :debugging
79
+
80
+ # Defines the logger used for debugging.
81
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
82
+ #
83
+ # @return [#debug]
84
+ attr_accessor :logger
85
+
86
+ # Defines the temporary folder to store downloaded files
87
+ # (for API endpoints that have file response).
88
+ # Default to use `Tempfile`.
89
+ #
90
+ # @return [String]
91
+ attr_accessor :temp_folder_path
92
+
93
+ # The time limit for HTTP request in seconds.
94
+ # Default to 0 (never times out).
95
+ attr_accessor :timeout
96
+
97
+ # Set this to false to skip client side validation in the operation.
98
+ # Default to true.
99
+ # @return [true, false]
100
+ attr_accessor :client_side_validation
101
+
102
+ ### TLS/SSL setting
103
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
104
+ # Default to true.
105
+ #
106
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
107
+ #
108
+ # @return [true, false]
109
+ attr_accessor :verify_ssl
110
+
111
+ ### TLS/SSL setting
112
+ # Set this to false to skip verifying SSL host name
113
+ # Default to true.
114
+ #
115
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
116
+ #
117
+ # @return [true, false]
118
+ attr_accessor :verify_ssl_host
119
+
120
+ ### TLS/SSL setting
121
+ # Set this to customize the certificate file to verify the peer.
122
+ #
123
+ # @return [String] the path to the certificate file
124
+ #
125
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
126
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
127
+ attr_accessor :ssl_ca_cert
128
+
129
+ ### TLS/SSL setting
130
+ # Client certificate file (for client certificate)
131
+ attr_accessor :cert_file
132
+
133
+ ### TLS/SSL setting
134
+ # Client private key file (for client certificate)
135
+ attr_accessor :key_file
136
+
137
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
138
+ # Default to nil.
139
+ #
140
+ # @see The params_encoding option of Ethon. Related source code:
141
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
142
+ attr_accessor :params_encoding
143
+
144
+
145
+ attr_accessor :inject_format
146
+
147
+ attr_accessor :force_ending_format
148
+
149
+ def initialize
150
+ @scheme = 'https'
151
+ @host = 'launchermeta.mojang.com'
152
+ @base_path = ''
153
+ @server_index = nil
154
+ @server_operation_index = {}
155
+ @server_variables = {}
156
+ @server_operation_variables = {}
157
+ @api_key = {}
158
+ @api_key_prefix = {}
159
+ @client_side_validation = true
160
+ @verify_ssl = true
161
+ @verify_ssl_host = true
162
+ @cert_file = nil
163
+ @key_file = nil
164
+ @timeout = 0
165
+ @params_encoding = nil
166
+ @debugging = false
167
+ @inject_format = false
168
+ @force_ending_format = false
169
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
170
+
171
+ yield(self) if block_given?
172
+ end
173
+
174
+ # The default Configuration object.
175
+ def self.default
176
+ @@default ||= Configuration.new
177
+ end
178
+
179
+ def configure
180
+ yield(self) if block_given?
181
+ end
182
+
183
+ def scheme=(scheme)
184
+ # remove :// from scheme
185
+ @scheme = scheme.sub(/:\/\//, '')
186
+ end
187
+
188
+ def host=(host)
189
+ # remove http(s):// and anything after a slash
190
+ @host = host.sub(/https?:\/\//, '').split('/').first
191
+ end
192
+
193
+ def base_path=(base_path)
194
+ # Add leading and trailing slashes to base_path
195
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
196
+ @base_path = '' if @base_path == '/'
197
+ end
198
+
199
+ # Returns base URL for specified operation based on server settings
200
+ def base_url(operation = nil)
201
+ if operation_server_settings.key?(operation) then
202
+ index = server_operation_index.fetch(operation, server_index)
203
+ server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
204
+ else
205
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
206
+ end
207
+ end
208
+
209
+ # Gets API key (with prefix if set).
210
+ # @param [String] param_name the parameter name of API key auth
211
+ def api_key_with_prefix(param_name, param_alias = nil)
212
+ key = @api_key[param_name]
213
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
214
+ if @api_key_prefix[param_name]
215
+ "#{@api_key_prefix[param_name]} #{key}"
216
+ else
217
+ key
218
+ end
219
+ end
220
+
221
+ # Gets access_token using access_token_getter or uses the static access_token
222
+ def access_token_with_refresh
223
+ return access_token if access_token_getter.nil?
224
+ access_token_getter.call
225
+ end
226
+
227
+ # Gets Basic Auth token string
228
+ def basic_auth_token
229
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
230
+ end
231
+
232
+ # Returns Auth Settings hash for api client.
233
+ def auth_settings
234
+ {
235
+ }
236
+ end
237
+
238
+ # Returns an array of Server setting
239
+ def server_settings
240
+ [
241
+ {
242
+ url: "https://launchermeta.mojang.com",
243
+ description: "No description provided",
244
+ },
245
+ {
246
+ url: "https://piston-meta.mojang.com",
247
+ description: "No description provided",
248
+ }
249
+ ]
250
+ end
251
+
252
+ def operation_server_settings
253
+ {
254
+ }
255
+ end
256
+
257
+ # Returns URL based on server settings
258
+ #
259
+ # @param index array index of the server settings
260
+ # @param variables hash of variable and the corresponding value
261
+ def server_url(index, variables = {}, servers = nil)
262
+ servers = server_settings if servers == nil
263
+
264
+ # check array index out of bound
265
+ if (index.nil? || index < 0 || index >= servers.size)
266
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
267
+ end
268
+
269
+ server = servers[index]
270
+ url = server[:url]
271
+
272
+ return url unless server.key? :variables
273
+
274
+ # go through variable and assign a value
275
+ server[:variables].each do |name, variable|
276
+ if variables.key?(name)
277
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
278
+ url.gsub! "{" + name.to_s + "}", variables[name]
279
+ else
280
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
281
+ end
282
+ else
283
+ # use default value
284
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
285
+ end
286
+ end
287
+
288
+ url
289
+ end
290
+
291
+
292
+ end
293
+ end
@@ -0,0 +1,230 @@
1
+ =begin
2
+ #SDK for Minecraft versions info
3
+
4
+ The version of the OpenAPI document: 0.10.0
5
+ Contact: blah+oapicf@cliffano.com
6
+ Generated by: https://openapi-generator.tech
7
+ Generator version: 7.6.0
8
+
9
+ =end
10
+
11
+ require 'date'
12
+ require 'time'
13
+
14
+ module MinecraftVersionsClient
15
+ class Download
16
+ attr_accessor :sha1
17
+
18
+ attr_accessor :size
19
+
20
+ attr_accessor :url
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'sha1' => :'sha1',
26
+ :'size' => :'size',
27
+ :'url' => :'url'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'sha1' => :'String',
40
+ :'size' => :'Integer',
41
+ :'url' => :'String'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MinecraftVersionsClient::Download` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MinecraftVersionsClient::Download`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'sha1')
67
+ self.sha1 = attributes[:'sha1']
68
+ end
69
+
70
+ if attributes.key?(:'size')
71
+ self.size = attributes[:'size']
72
+ end
73
+
74
+ if attributes.key?(:'url')
75
+ self.url = attributes[:'url']
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
+ invalid_properties = Array.new
84
+ invalid_properties
85
+ end
86
+
87
+ # Check to see if the all the properties in the model are valid
88
+ # @return true if the model is valid
89
+ def valid?
90
+ warn '[DEPRECATED] the `valid?` method is obsolete'
91
+ true
92
+ end
93
+
94
+ # Checks equality by comparing each attribute.
95
+ # @param [Object] Object to be compared
96
+ def ==(o)
97
+ return true if self.equal?(o)
98
+ self.class == o.class &&
99
+ sha1 == o.sha1 &&
100
+ size == o.size &&
101
+ url == o.url
102
+ end
103
+
104
+ # @see the `==` method
105
+ # @param [Object] Object to be compared
106
+ def eql?(o)
107
+ self == o
108
+ end
109
+
110
+ # Calculates hash code according to all attributes.
111
+ # @return [Integer] Hash code
112
+ def hash
113
+ [sha1, size, url].hash
114
+ end
115
+
116
+ # Builds the object from hash
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ # @return [Object] Returns the model itself
119
+ def self.build_from_hash(attributes)
120
+ return nil unless attributes.is_a?(Hash)
121
+ attributes = attributes.transform_keys(&:to_sym)
122
+ transformed_hash = {}
123
+ openapi_types.each_pair do |key, type|
124
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
125
+ transformed_hash["#{key}"] = nil
126
+ elsif type =~ /\AArray<(.*)>/i
127
+ # check to ensure the input is an array given that the attribute
128
+ # is documented as an array but the input is not
129
+ if attributes[attribute_map[key]].is_a?(Array)
130
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
131
+ end
132
+ elsif !attributes[attribute_map[key]].nil?
133
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
134
+ end
135
+ end
136
+ new(transformed_hash)
137
+ end
138
+
139
+ # Deserializes the data based on type
140
+ # @param string type Data type
141
+ # @param string value Value to be deserialized
142
+ # @return [Object] Deserialized data
143
+ def self._deserialize(type, value)
144
+ case type.to_sym
145
+ when :Time
146
+ Time.parse(value)
147
+ when :Date
148
+ Date.parse(value)
149
+ when :String
150
+ value.to_s
151
+ when :Integer
152
+ value.to_i
153
+ when :Float
154
+ value.to_f
155
+ when :Boolean
156
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
157
+ true
158
+ else
159
+ false
160
+ end
161
+ when :Object
162
+ # generic object (usually a Hash), return directly
163
+ value
164
+ when /\AArray<(?<inner_type>.+)>\z/
165
+ inner_type = Regexp.last_match[:inner_type]
166
+ value.map { |v| _deserialize(inner_type, v) }
167
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
168
+ k_type = Regexp.last_match[:k_type]
169
+ v_type = Regexp.last_match[:v_type]
170
+ {}.tap do |hash|
171
+ value.each do |k, v|
172
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
173
+ end
174
+ end
175
+ else # model
176
+ # models (e.g. Pet) or oneOf
177
+ klass = MinecraftVersionsClient.const_get(type)
178
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
179
+ end
180
+ end
181
+
182
+ # Returns the string representation of the object
183
+ # @return [String] String presentation of the object
184
+ def to_s
185
+ to_hash.to_s
186
+ end
187
+
188
+ # to_body is an alias to to_hash (backward compatibility)
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_body
191
+ to_hash
192
+ end
193
+
194
+ # Returns the object in the form of hash
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_hash
197
+ hash = {}
198
+ self.class.attribute_map.each_pair do |attr, param|
199
+ value = self.send(attr)
200
+ if value.nil?
201
+ is_nullable = self.class.openapi_nullable.include?(attr)
202
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
203
+ end
204
+
205
+ hash[param] = _to_hash(value)
206
+ end
207
+ hash
208
+ end
209
+
210
+ # Outputs non-array value in the form of hash
211
+ # For object, use to_hash. Otherwise, just return the value
212
+ # @param [Object] value Any valid value
213
+ # @return [Hash] Returns the value in the form of hash
214
+ def _to_hash(value)
215
+ if value.is_a?(Array)
216
+ value.compact.map { |v| _to_hash(v) }
217
+ elsif value.is_a?(Hash)
218
+ {}.tap do |hash|
219
+ value.each { |k, v| hash[k] = _to_hash(v) }
220
+ end
221
+ elsif value.respond_to? :to_hash
222
+ value.to_hash
223
+ else
224
+ value
225
+ end
226
+ end
227
+
228
+ end
229
+
230
+ end