{"id":19933013,"url":"https://github.com/kontena/kong-client-ruby","last_synced_at":"2025-11-09T11:01:31.635Z","repository":{"id":56880413,"uuid":"63222125","full_name":"kontena/kong-client-ruby","owner":"kontena","description":"Kong API client for Ruby","archived":false,"fork":false,"pushed_at":"2023-01-30T17:09:07.000Z","size":66,"stargazers_count":42,"open_issues_count":8,"forks_count":34,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-09T19:20:01.098Z","etag":null,"topics":["kong","kong-client","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kontena.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-13T06:54:07.000Z","updated_at":"2024-01-18T09:19:47.000Z","dependencies_parsed_at":"2023-02-13T03:05:43.754Z","dependency_job_id":null,"html_url":"https://github.com/kontena/kong-client-ruby","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fkong-client-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fkong-client-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fkong-client-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fkong-client-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kontena","download_url":"https://codeload.github.com/kontena/kong-client-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094991,"owners_count":21046770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kong","kong-client","ruby"],"created_at":"2024-11-12T23:12:19.273Z","updated_at":"2025-10-17T23:49:11.889Z","avatar_url":"https://github.com/kontena.png","language":"Ruby","readme":"# Kong Client for Ruby\n\n[Kong](http://getkong.org) API client for Ruby\n\n[![Build Status](https://travis-ci.org/kontena/kong-client-ruby.svg?branch=master)](https://travis-ci.org/kontena/kong-client-ruby)\n[![Gem Version](https://badge.fury.io/rb/kong.svg)](https://badge.fury.io/rb/kong)\n\n## Installation\nAdd this line to your application's Gemfile:\n\n    gem 'kong'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install kong\n\n## Usage\n\nBy default Kong client tries to connect `http://localhost:8001` or address provided by environment variable: `KONG_URI='http://your-kong-url:8001'`.\n\nYou can set it also in your code:\n```ruby\nrequire 'kong'\nKong::Client.api_url = 'http://your-kong-url:8001'\n```\n\n### Design\n\nKong client follows a design of resoures as Plain Old Ruby objects(tm). For examples to create a new Consumer resource you can do it like this:\n\n```ruby\nconsumer = Kong::Consumer.create({ username: 'testuser', custom_id: 'custom_id' })\n```\n\nOR\n\n```ruby\nconsumer = Kong::Consumer.new({ username: 'testuser'})\nconsumer.custom_id = '12345'\nconsumer.save\n```\n\nTo find existing consumer:\n\n```ruby\nconsumer = Kong::Consumer.find_by_username('testuser')\nconsumer = Kong::Consumer.find_by_custom_id('custom_id')\n```\n\n### All Resources and Actions\n\nTo see the complete Kong Admin API documentation, please visit: https://getkong.org/docs/0.11.x/admin-api/\n\n#### Consumer\n\n```ruby\nKong::Consumer.list(filters)\nKong::Consumer.all()\nKong::Consumer.find(id)\nKong::Consumer.find_by_*(value)\nKong::Consumer.create(attributes)\n\nconsumer = Kong::Consumer.new({ username: 'test-user' })\nconsumer.get # reloads resource\nconsumer.create\nconsumer.update\nconsumer.save # requests create_or_update action\nconsumer.delete\n\nconsumer.plugins\nconsumer.oauth_apps\nconsumer.key_auths\nconsumer.basic_auths\nconsumer.oauth2_tokens\n```\n\n#### API\n\n```ruby\nKong::Api.list(filters)\nKong::Api.all()\nKong::Api.find(id)\nKong::Api.find_by_*(value)\nKong::Api.create(attributes)\n\napi = Kong::Api.new({\n  name: 'Mockbin',\n  hosts: ['example.com'],\n  uris: ['/someservice'],\n  methods: ['GET'],\n  strip_uri: false,\n  preserve_host: false,\n  upstream_url: 'https://mockbin.com'\n})\napi.get # reloads resource\napi.create\napi.update\napi.save # requests create_or_update action\napi.delete\n\napi.plugins\n```\n\n#### Plugin\n\n```ruby\nKong::Plugin.list(filters)\nKong::Plugin.all()\nKong::Plugin.find(id)\nKong::Plugin.find_by_*(value)\nKong::Plugin.create(attributes)\n\nplugin = Kong::Plugin.new({\n  api_id: '5fd1z584-1adb-40a5-c042-63b19db49x21',\n  consumer_id: 'a3dX2dh2-1adb-40a5-c042-63b19dbx83hF4',\n  name: 'rate-limiting',\n  config: {\n    minute: 20,\n    hour: 500\n  }\n})\n\nplugin.get # reloads resource\nplugin.create\nplugin.update\nplugin.save # requests create_or_update action\nplugin.delete\n```\n\n#### Upstream and Targets (for load-balanced APIs)\n\n```ruby\nKong::Upstream.list(filters)\nKong::Upstream.all()\nKong::Upstream.find(id)\nKong::Upstream.find_by_*(value)\nKong::Upstream.create(attributes)\n\nupstream = Kong::Upstream.new({ name: 'myservice' })\n\nupstream.get # reloads resource\nupstream.create\nupstream.update\nupstream.save # requests create_or_update action\nupstream.delete\n\nupstream.targets # lists active targets\n\n# Add targets\nKong::Target.new({ upstream_id: upstream.id, target: 'appserver1:80' }).save\nKong::Target.new({ upstream_id: upstream.id, target: 'appserver2:80' }).save\n\n# Add the API\nKong::Api.new({\n  ...\n  upstream_url: 'http://myservice'\n}).save\n```\n\n#### OAuthApp\n\n```ruby\nKong::OAuthApp.list(filters)\nKong::OAuthApp.all()\nKong::OAuthApp.find(consumer_id)\nKong::OAuthApp.find_by_*(value)\nKong::OAuthApp.create(attributes)\n\napp = Kong::OAuthApp.new({\n  consumer_id: 'a3dX2dh2-1adb-40a5-c042-63b19dbx83hF4',\n  redirect_uri: 'http://some-domain/endpoint/'\n})\n\napp.create\napp.get # reloads resource\napp.update\napp.save # requests create_or_update action\napp.delete\n```\n\n#### KeyAuth\n\n```ruby\nKong::KeyAuth.create(attributes)\n\nauth = Kong::KeyAuth.new({\n  consumer_id: 'a3dX2dh2-1adb-40a5-c042-63b19dbx83hF4',\n})\n\nauth.create\nauth.get # reloads resource\nauth.update\nauth.save # requests create_or_update action\nauth.delete\n```\n\n#### BasicAuth\n\n```ruby\nKong::BasicAuth.create(attributes)\n\nauth = Kong::BasicAuth.new({\n  consumer_id: 'a3dX2dh2-1adb-40a5-c042-63b19dbx83hF4',\n  username: 'user123',\n  password: 'secret'\n})\n\nauth.create\nauth.get # reloads resource\nauth.update\nauth.save # requests create_or_update action\nauth.delete\n```\n\n#### OAuth2Token\n\n```ruby\ntoken = Kong::OAuth2Token.find_by_access_token('SOME-TOKEN')\n\ntoken = Kong::OAuth2Token.new({\n  credential_id: 'KONG-APPLICATION-ID',\n  token_type: 'bearer',\n  access_token: 'SOME-TOKEN',\n  refresh_token: 'SOME-TOKEN',\n  expires_in: 3600\n})\n\ntoken.create\ntoken.update\ntoken.save # requests create_or_update action\ntoken.delete\n\ntoken.oauth_app\n```\n\n#### JWT\n\n```ruby\n\njwt = Kong::JWT.new({\n  consumer_id: 'a3dX2dh2-1adb-40a5-c042-63b19dbx83hF4',\n  key: 'a36c3049b36249a3c9f8891cb127243c',\n  secret: 'e71829c351aa4242c2719cbfbe671c09'\n})\n\njwt.create\njwt.update\njwt.save # requests create_or_update action\njwt.delete\n\nconsumer = Kong::Consumer.find_by_username('testuser')\nconsumer.jwts\n```\n\n#### ACL\n\n```ruby\n\nacl = Kong::Acl.new({\n  consumer_id: 'a3dX2dh2-1adb-40a5-c042-63b19dbx83hF4',\n  group: 'group1'\n})\n\nacl.create\nacl.update\nacl.save # requests create_or_update action\nacl.delete\n\nconsumer = Kong::Consumer.find_by_username('testuser')\nconsumer.acls\n```\n\n#### Server Information\n\n```ruby\nKong::Server.info\nKong::Server.version\nKong::Server.status\nKong::Server.cluster\nKong::Server.remove_node(node_name)\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/kontena/kong-client-ruby/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkontena%2Fkong-client-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkontena%2Fkong-client-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkontena%2Fkong-client-ruby/lists"}