diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index d71e919..baf9ec7 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -52,6 +52,8 @@ docs/PackUsers.md docs/Packs.md docs/Profile.md docs/ProfileApi.md +docs/Provider.md +docs/Providers.md docs/Quilt.md docs/QuiltApi.md docs/QuiltBuildParams.md @@ -143,6 +145,8 @@ lib/kleister/models/pack_user_params.rb lib/kleister/models/pack_users.rb lib/kleister/models/packs.rb lib/kleister/models/profile.rb +lib/kleister/models/provider.rb +lib/kleister/models/providers.rb lib/kleister/models/quilt.rb lib/kleister/models/quilt_build_params.rb lib/kleister/models/quilt_builds.rb @@ -176,4 +180,6 @@ lib/kleister/models/version_builds.rb lib/kleister/models/version_file.rb lib/kleister/models/versions.rb lib/kleister/version.rb +spec/models/provider_spec.rb +spec/models/providers_spec.rb spec/spec_helper.rb diff --git a/docs/AuthApi.md b/docs/AuthApi.md index dd2967b..8db5af9 100644 --- a/docs/AuthApi.md +++ b/docs/AuthApi.md @@ -6,6 +6,7 @@ All URIs are relative to *https://try.kleister.eu/api/v1* | ------ | ------------ | ----------- | | [**external_callback**](AuthApi.md#external_callback) | **GET** /auth/{provider}/callback | Callback for external authentication | | [**external_initialize**](AuthApi.md#external_initialize) | **GET** /auth/{provider}/initialize | Initialize the external authentication | +| [**external_providers**](AuthApi.md#external_providers) | **GET** /auth/providers | Fetch the available auth providers | | [**login_auth**](AuthApi.md#login_auth) | **POST** /auth/login | Authenticate an user by credentials | | [**refresh_auth**](AuthApi.md#refresh_auth) | **GET** /auth/refresh | Refresh an auth token before it expires | | [**verify_auth**](AuthApi.md#verify_auth) | **GET** /auth/verify | Verify validity for an authentication token | @@ -145,6 +146,65 @@ No authorization required - **Accept**: application/json +## external_providers + +> external_providers + +Fetch the available auth providers + +### Examples + +```ruby +require 'time' +require 'kleister' + +api_instance = Kleister::AuthApi.new + +begin + # Fetch the available auth providers + result = api_instance.external_providers + p result +rescue Kleister::ApiError => e + puts "Error when calling AuthApi->external_providers: #{e}" +end +``` + +#### Using the external_providers_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> external_providers_with_http_info + +```ruby +begin + # Fetch the available auth providers + data, status_code, headers = api_instance.external_providers_with_http_info + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Kleister::ApiError => e + puts "Error when calling AuthApi->external_providers_with_http_info: #{e}" +end +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Providers**](Providers.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + ## login_auth > login_auth(auth_login) diff --git a/docs/Provider.md b/docs/Provider.md new file mode 100644 index 0000000..b990551 --- /dev/null +++ b/docs/Provider.md @@ -0,0 +1,24 @@ +# Kleister::Provider + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | | [optional][readonly] | +| **driver** | **String** | | [optional][readonly] | +| **display** | **String** | | [optional][readonly] | +| **icon** | **String** | | [optional][readonly] | + +## Example + +```ruby +require 'kleister' + +instance = Kleister::Provider.new( + name: null, + driver: null, + display: null, + icon: null +) +``` + diff --git a/docs/Providers.md b/docs/Providers.md new file mode 100644 index 0000000..c4062b7 --- /dev/null +++ b/docs/Providers.md @@ -0,0 +1,20 @@ +# Kleister::Providers + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **total** | **Integer** | | [optional] | +| **listing** | [**Array<Provider>**](Provider.md) | | [optional] | + +## Example + +```ruby +require 'kleister' + +instance = Kleister::Providers.new( + total: null, + listing: null +) +``` + diff --git a/lib/kleister.rb b/lib/kleister.rb index 8631855..f045dca 100644 --- a/lib/kleister.rb +++ b/lib/kleister.rb @@ -56,6 +56,8 @@ require 'kleister/models/pack_users' require 'kleister/models/packs' require 'kleister/models/profile' +require 'kleister/models/provider' +require 'kleister/models/providers' require 'kleister/models/quilt' require 'kleister/models/quilt_build_params' require 'kleister/models/quilt_builds' diff --git a/lib/kleister/api/auth_api.rb b/lib/kleister/api/auth_api.rb index 5708b37..ed22912 100644 --- a/lib/kleister/api/auth_api.rb +++ b/lib/kleister/api/auth_api.rb @@ -151,6 +151,61 @@ def external_initialize_with_http_info(provider, opts = {}) [data, status_code, headers] end + # Fetch the available auth providers + # @param [Hash] opts the optional parameters + # @return [Providers] + def external_providers(opts = {}) + data, _status_code, _headers = external_providers_with_http_info(opts) + data + end + + # Fetch the available auth providers + # @param [Hash] opts the optional parameters + # @return [Array<(Providers, Integer, Hash)>] Providers data, response status code and response headers + def external_providers_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: AuthApi.external_providers ...' + end + # resource path + local_var_path = '/auth/providers' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Providers' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + operation: :'AuthApi.external_providers', + header_params: header_params, + query_params: query_params, + form_params: form_params, + body: post_body, + auth_names: auth_names, + return_type: return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: AuthApi#external_providers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + [data, status_code, headers] + end + # Authenticate an user by credentials # @param auth_login [AuthLogin] The credentials to authenticate # @param [Hash] opts the optional parameters diff --git a/lib/kleister/models/provider.rb b/lib/kleister/models/provider.rb new file mode 100644 index 0000000..90bbf8b --- /dev/null +++ b/lib/kleister/models/provider.rb @@ -0,0 +1,234 @@ +# Kleister OpenAPI +# +# API definition for Kleister, manage mod packs for Minecraft +# +# The version of the OpenAPI document: 1.0.0-alpha1 +# Contact: kleister@webhippie.de +# Generated by: https://openapi-generator.tech +# Generator version: 7.6.0 +# + +require 'date' +require 'time' + +module Kleister + # Model to represent auth provider + class Provider + attr_accessor :name, :driver, :display, :icon + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + name: :name, + driver: :driver, + display: :display, + icon: :icon + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + name: :String, + driver: :String, + display: :String, + icon: :String + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, 'The input argument (attributes) must be a hash in `Kleister::Provider` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) do |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `Kleister::Provider`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + + h[k.to_sym] = v + end + + if attributes.key?(:name) + self.name = attributes[:name] + end + + if attributes.key?(:driver) + self.driver = attributes[:driver] + end + + if attributes.key?(:display) + self.display = attributes[:display] + end + + if attributes.key?(:icon) + self.icon = attributes[:icon] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + [] + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + + self.class == other.class && + name == other.name && + driver == other.driver && + display == other.display && + icon == other.icon + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, driver, display, icon].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash[key.to_s] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Kleister.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/kleister/models/providers.rb b/lib/kleister/models/providers.rb new file mode 100644 index 0000000..6307f1c --- /dev/null +++ b/lib/kleister/models/providers.rb @@ -0,0 +1,220 @@ +# Kleister OpenAPI +# +# API definition for Kleister, manage mod packs for Minecraft +# +# The version of the OpenAPI document: 1.0.0-alpha1 +# Contact: kleister@webhippie.de +# Generated by: https://openapi-generator.tech +# Generator version: 7.6.0 +# + +require 'date' +require 'time' + +module Kleister + # Model to represent list of auth providers + class Providers + attr_accessor :total, :listing + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + total: :total, + listing: :listing + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + total: :Integer, + listing: :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + unless attributes.is_a?(Hash) + raise ArgumentError, 'The input argument (attributes) must be a hash in `Kleister::Providers` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) do |(k, v), h| + unless self.class.attribute_map.key?(k.to_sym) + raise ArgumentError, "`#{k}` is not a valid attribute in `Kleister::Providers`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + + h[k.to_sym] = v + end + + if attributes.key?(:total) + self.total = attributes[:total] + end + + if attributes.key?(:listing) && (value = attributes[:listing]).is_a?(Array) + self.listing = value + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + [] + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(other) + return true if equal?(other) + + self.class == other.class && + total == other.total && + listing == other.listing + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(other) + self == other + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [total, listing].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash[key.to_s] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Kleister.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/spec/models/provider_spec.rb b/spec/models/provider_spec.rb new file mode 100644 index 0000000..96d0c58 --- /dev/null +++ b/spec/models/provider_spec.rb @@ -0,0 +1,51 @@ +# Kleister OpenAPI +# +# API definition for Kleister, manage mod packs for Minecraft +# +# The version of the OpenAPI document: 1.0.0-alpha1 +# Contact: kleister@webhippie.de +# Generated by: https://openapi-generator.tech +# Generator version: 7.6.0 +# + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Kleister::Provider +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe Kleister::Provider do + let(:instance) { Kleister::Provider.new } + + describe 'test an instance of Provider' do + it 'should create an instance of Provider' do + # uncomment below to test the instance creation + # expect(instance).to be_instance_of(Kleister::Provider) + end + end + + describe 'test attribute "name"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + + describe 'test attribute "driver"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + + describe 'test attribute "display"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + + describe 'test attribute "icon"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end +end diff --git a/spec/models/providers_spec.rb b/spec/models/providers_spec.rb new file mode 100644 index 0000000..b76f060 --- /dev/null +++ b/spec/models/providers_spec.rb @@ -0,0 +1,39 @@ +# Kleister OpenAPI +# +# API definition for Kleister, manage mod packs for Minecraft +# +# The version of the OpenAPI document: 1.0.0-alpha1 +# Contact: kleister@webhippie.de +# Generated by: https://openapi-generator.tech +# Generator version: 7.6.0 +# + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Kleister::Providers +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe Kleister::Providers do + let(:instance) { Kleister::Providers.new } + + describe 'test an instance of Providers' do + it 'should create an instance of Providers' do + # uncomment below to test the instance creation + # expect(instance).to be_instance_of(Kleister::Providers) + end + end + + describe 'test attribute "total"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + + describe 'test attribute "listing"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end +end