kontena / kong-client-ruby Goto Github PK
View Code? Open in Web Editor NEWKong API client for Ruby
License: Apache License 2.0
Kong API client for Ruby
License: Apache License 2.0
Hello,
As said in the doc, it should be possible to override the default kong_url with this code
Kong::Client.api_url = 'http://your-kong-url:8001'
However, this does not work. The api_url
attribute is changed, but the Excon http_client is not updated as it is called only once in Kong::Client#initialize
This results in using the default kong url http://localhost:8001
and not the one set in api_url
attribute
Basically this breaks save
method that uses PUT
for creating or updating resources.
See: Kong/kong#3416
When I try to load the last version (0.3.3) of the gem, installed from rubygems, it launches the below error:
$ bundle exec rake assets:precompile
rake aborted!
LoadError: cannot load such file -- /Users/x/.rvm/gems/ruby-2.5.0@global/gems/kong-0.3.3/lib/kong/service
/Users/x/.rvm/gems/ruby-2.5.0@global/gems/kong-0.3.3/lib/kong.rb:5:in `require_relative'
/Users/x/.rvm/gems/ruby-2.5.0@global/gems/kong-0.3.3/lib/kong.rb:5:in `<top (required)>'
...
(See full trace by running task with --trace)
The file lib/kong.rb
installed on my machine is pretty different from the one in the repository.
Instead of Api object there are now Service and Route objects
It looks like key_auths
method only returns the first 100 records, seems no way to retrieve more
If I create a Kong consumer using only a custom_id
(so have no username
) I'm unable to retrieve that consumers JWTs using Kong::Consumer.find_by_custom_id("foo").jwts
.
I did some digging and in lib/kong/consumer.rb
line 94, the client call to get the JWTs is usingclient.get("#{@api_end_point}#{self.username}/jwt")
but because username is nil nothing is returned.
Should (or could) this be more like client.get("#{@api_end_point}#{self.username || self.custom_id}/jwt")
?
Hello,
I tried to call the delete
method on a consumer object but it crashed :
Kong::Error: {"message":"An unexpected error occurred"}
The SQL log of my kong server displays :
db_1 | ERROR: operator does not exist: text = boolean at character 270
db_1 | HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
db_1 | STATEMENT: SELECT COUNT(*) FROM oauth2_tokens LEFT OUTER JOIN ttls ON (oauth2_tokens.id = ttls.primary_uuid_value) WHERE
db_1 | (ttls.primary_key_value IS NULL OR (ttls.table_name = 'oauth2_tokens' AND expire_at > CURRENT_TIMESTAMP(0) at time zone 'utc')) AND "authenticated_userid" = TRUE
After some investigation, I found what caused the issue : https://github.com/kontena/kong-client-ruby/blob/master/lib/kong/consumer.rb#L68
Since the consumer object I'm working on, does not have a custom_id attribute set, this method send {authenticated_userid:nil }
as params which will then be encoded as "authenticated_userid"
and then seems to be evaluted to TRUE in PostgreSQL.
I don't know what would be the best way to solve this issue :
Kong::Client#encode_params
method to return "param_name=null"
in case of nil values.authenticated_userid
param if custom_id is nil in Kong::Consumer#oauth_tokens
methodWhat do you think ?
Thank you for your work on this gem by the way :)
When adding an API in Kong v0.11.0 there is a semi-optional value methods
which is a comma-separated list of HTTP methods that point to the API.
This is a great contribution to the Kong community - thanks!
I invite you to add this to Kong Hub https://docs.konghq.com/hub/ - see https://github.com/Kong/docs.konghq.com/blob/master/CONTRIBUTING.md#contributing-to-kong-documentation-and-the-kong-hub for details.
Once added, it'd be great if you'd like to announce it on Kong Nation https://discuss.konghq.com/c/announcements
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.