kongkit 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kongkit/client/api_object.rb +4 -4
- data/lib/kongkit/client/cluster.rb +1 -1
- data/lib/kongkit/client/consumer.rb +4 -4
- data/lib/kongkit/client/key_authentication.rb +39 -0
- data/lib/kongkit/client/node.rb +2 -2
- data/lib/kongkit/client/plugin_object.rb +7 -7
- data/lib/kongkit/client/resource.rb +7 -0
- data/lib/kongkit/client.rb +2 -0
- data/lib/kongkit/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21a9625c262f22f83140da50758d765ca8f12f7a
|
4
|
+
data.tar.gz: 5ca591d272826074cc520e911665ded42fc54ef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a65d61a31eb747b5aabfbc8a316b23e1d53f733548985e1457cd9c1733566ac0c419e8029c66fb2b71296e7f1130da9acdbabe9b5dcf9052d1a0666b2148ebc4
|
7
|
+
data.tar.gz: 3e683b2a70ec57c49999bbc96e04bacd4e23fdc99e7f580dbb0daa851024d6a965e9093585ec985f08d8ad5b27a0e29fd49320152d4ced543589546dd608fb84
|
@@ -11,7 +11,7 @@ module Kongkit
|
|
11
11
|
# @option options [String] :upstream_url A filter on the list based on the apis `upstream_url` field
|
12
12
|
# @option options [Integer] :size A limit on the number of objects to be returned, default: 100
|
13
13
|
# @option options [String] :offset A cursor used for pagination. Offset is an object identifier that defines a place in the list.
|
14
|
-
# @return [
|
14
|
+
# @return [Kongkit::Client::Resource] API Objects
|
15
15
|
def apis(options = {})
|
16
16
|
get('/apis', query: options)
|
17
17
|
end
|
@@ -20,7 +20,7 @@ module Kongkit
|
|
20
20
|
#
|
21
21
|
# @see https://getkong.org/docs/0.8.x/admin-api/#retrieve-api
|
22
22
|
# @param identifier [String] The unique identifier or the name of the API to retrieve
|
23
|
-
# @return [
|
23
|
+
# @return [Kongkit::Client::Resource] API Object
|
24
24
|
def api(identifier)
|
25
25
|
get(api_path(identifier))
|
26
26
|
end
|
@@ -36,7 +36,7 @@ module Kongkit
|
|
36
36
|
# @option attributes [String] :strip_request_path Strip the request_path value before proxying the request to the final API (optional)
|
37
37
|
# @option attributes [String] :preserve_host Preserves the original Host header sent by the client, instead of replacing it with the hostname of the upstream_url (optional)
|
38
38
|
# @option attributes [String] :upstream_url The base target URL that points to your API server, this URL will be used for proxying requests
|
39
|
-
# @return [
|
39
|
+
# @return [Kongkit::Client::Resource] API Object
|
40
40
|
def add_api(attributes)
|
41
41
|
post('/apis', body: attributes)
|
42
42
|
end
|
@@ -53,7 +53,7 @@ module Kongkit
|
|
53
53
|
# @option attributes [String] :strip_request_path Strip the request_path value before proxying the request to the final API (optional)
|
54
54
|
# @option attributes [String] :preserve_host Preserves the original Host header sent by the client, instead of replacing it with the hostname of the upstream_url (optional)
|
55
55
|
# @option attributes [String] :upstream_url The base target URL that points to your API server, this URL will be used for proxying requests
|
56
|
-
# @return [
|
56
|
+
# @return [Kongkit::Client::Resource] API Object
|
57
57
|
def edit_api(identifier, attributes)
|
58
58
|
patch(api_path(identifier), body: attributes)
|
59
59
|
end
|
@@ -6,7 +6,7 @@ module Kongkit
|
|
6
6
|
# Retrieve the cluster status, returning information for each node in the cluster.
|
7
7
|
#
|
8
8
|
# @see https://getkong.org/docs/0.8.x/admin-api/#retrieve-cluster-status
|
9
|
-
# @return [
|
9
|
+
# @return [Kongkit::Client::Resource] Cluster status
|
10
10
|
def cluster_status
|
11
11
|
get('/cluster')
|
12
12
|
end
|
@@ -9,7 +9,7 @@ module Kongkit
|
|
9
9
|
# @option options [String] :username A filter on the list based on the consumer `username` field
|
10
10
|
# @option options [Integer] :size A limit on the number of objects to be returned, default: 100
|
11
11
|
# @option options [String] :offset A cursor used for pagination. Offset is an object identifier that defines a place in the list.
|
12
|
-
# @return [
|
12
|
+
# @return [Kongkit::Client::Resource] API Objects
|
13
13
|
def consumers(options = {})
|
14
14
|
get('/consumers', query: options)
|
15
15
|
end
|
@@ -18,7 +18,7 @@ module Kongkit
|
|
18
18
|
#
|
19
19
|
# @see https://getkong.org/docs/0.8.x/admin-api/#retrieve-consumer
|
20
20
|
# @param identifier [String] The unique identifier or the username of the consumer to retrieve
|
21
|
-
# @return [
|
21
|
+
# @return [Kongkit::Client::Resource] Consumer
|
22
22
|
def consumer(identifier)
|
23
23
|
get(consumer_path(identifier))
|
24
24
|
end
|
@@ -30,7 +30,7 @@ module Kongkit
|
|
30
30
|
# @see https://getkong.org/docs/0.8.x/admin-api/#create-consumer
|
31
31
|
# @option attributes [String] :username The username of the consumer (semi-optional)
|
32
32
|
# @option attributes [String] :custom_id Field for storing an existing ID for the consumer, useful for mapping Kong with users in your existing database (semi-optional)
|
33
|
-
# @return [
|
33
|
+
# @return [Kongkit::Client::Resource] Consumer
|
34
34
|
def create_consumer(attributes)
|
35
35
|
post('/consumers', body: attributes)
|
36
36
|
end
|
@@ -43,7 +43,7 @@ module Kongkit
|
|
43
43
|
# @param identifier [String] The unique identifier or the name of the consumer to update
|
44
44
|
# @option attributes [String] :username The username of the consumer (semi-optional)
|
45
45
|
# @option attributes [String] :custom_id Field for storing an existing ID for the consumer, useful for mapping Kong with users in your existing database (semi-optional)
|
46
|
-
# @return [
|
46
|
+
# @return [Kongkit::Client::Resource] Consumer
|
47
47
|
def edit_consumer(identifier, attributes)
|
48
48
|
patch(consumer_path(identifier), body: attributes)
|
49
49
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Kongkit
|
2
|
+
class Client
|
3
|
+
module KeyAuthentication
|
4
|
+
# List Auth Keys for the given consumer
|
5
|
+
#
|
6
|
+
# @see https://getkong.org/plugins/key-authentication/
|
7
|
+
# @param identifier [String] The unique identifier or the username of the consumer
|
8
|
+
# @return [Kongkit::Client::Resource] Auth Keys
|
9
|
+
def auth_keys(identifier)
|
10
|
+
get(auth_key_path(identifier))
|
11
|
+
end
|
12
|
+
|
13
|
+
# Create a new Auth Key for the given consumer
|
14
|
+
#
|
15
|
+
# @see https://getkong.org/plugins/key-authentication/
|
16
|
+
# @param identifier [String] The unique identifier or the username of the consumer
|
17
|
+
# @return [Kongkit::Client::Resource] Auth Keys
|
18
|
+
def add_auth_key(identifier)
|
19
|
+
post(auth_key_path(identifier))
|
20
|
+
end
|
21
|
+
|
22
|
+
# Delete Auth Key
|
23
|
+
#
|
24
|
+
# @see https://getkong.org/docs/0.8.x/admin-api/#delete-consumer
|
25
|
+
# @param identifier [String] The unique identifier or the name of the consumer to delete
|
26
|
+
# @param id [String] The unique identifier of the Auth Key
|
27
|
+
# @return [Boolean] `true` if successfully deleted
|
28
|
+
def delete_auth_key(identifier, id)
|
29
|
+
delete("#{auth_key_path(identifier)}/#{id}")
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def auth_key_path(identifier)
|
35
|
+
"#{consumer_path(identifier)}/key-auth"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/kongkit/client/node.rb
CHANGED
@@ -6,7 +6,7 @@ module Kongkit
|
|
6
6
|
# Retrieve generic details about a node.
|
7
7
|
#
|
8
8
|
# @see https://getkong.org/docs/0.8.x/admin-api/#retrieve-node-information
|
9
|
-
# @return [
|
9
|
+
# @return [Kongkit::Client::Resource] Node information
|
10
10
|
def node_information
|
11
11
|
get('/')
|
12
12
|
end
|
@@ -22,7 +22,7 @@ module Kongkit
|
|
22
22
|
# every existing nginx monitoring tool or agent can be used.
|
23
23
|
#
|
24
24
|
# @see https://getkong.org/docs/0.8.x/admin-api/#retrieve-node-status
|
25
|
-
# @return [
|
25
|
+
# @return [Kongkit::Client::Resource] Node status
|
26
26
|
def node_status
|
27
27
|
get('/status')
|
28
28
|
end
|
@@ -10,7 +10,7 @@ module Kongkit
|
|
10
10
|
# @option options [String] :consumer_id A filter on the list based on the `consumer_id` field
|
11
11
|
# @option options [Integer] :size A limit on the number of objects to be returned, default: 100
|
12
12
|
# @option options [offset] :offset A cursor used for pagination. offset is an object identifier that defines a place in the list.
|
13
|
-
# @return [
|
13
|
+
# @return [Kongkit::Client::Resource] Plugin Objects
|
14
14
|
def plugins(options = {})
|
15
15
|
get('/plugins', options)
|
16
16
|
end
|
@@ -20,7 +20,7 @@ module Kongkit
|
|
20
20
|
# Retrieve a list of all installed plugins on the Kong node.
|
21
21
|
#
|
22
22
|
# @see https://getkong.org/docs/0.8.x/admin-api/#list-enabled-plugins
|
23
|
-
# @return [
|
23
|
+
# @return [Kongkit::Client::Resource] Plugin Objects
|
24
24
|
def enabled_plugins
|
25
25
|
get('/plugins/enabled')
|
26
26
|
end
|
@@ -33,7 +33,7 @@ module Kongkit
|
|
33
33
|
#
|
34
34
|
# @see https://getkong.org/docs/0.8.x/admin-api/#list-enabled-plugins
|
35
35
|
# @param name [String] The name of the plugin to retrieve its schema
|
36
|
-
# @return [
|
36
|
+
# @return [Kongkit::Client::Resource] Plugin Objects
|
37
37
|
def plugin_schema(name)
|
38
38
|
get("/plugins/schema/#{name}")
|
39
39
|
end
|
@@ -42,7 +42,7 @@ module Kongkit
|
|
42
42
|
#
|
43
43
|
# @see https://getkong.org/docs/0.8.x/admin-api/#retrieve-plugin
|
44
44
|
# @param id [String] The unique identifier of the plugin to retrieve
|
45
|
-
# @return [
|
45
|
+
# @return [Kongkit::Client::Resource] Plugin Object
|
46
46
|
def plugin(id)
|
47
47
|
get("/plugins/#{id}")
|
48
48
|
end
|
@@ -57,7 +57,7 @@ module Kongkit
|
|
57
57
|
# @option options [String] :consumer_id A filter on the list based on the `consumer_id` field
|
58
58
|
# @option options [Integer] :size A limit on the number of objects to be returned, default: 100
|
59
59
|
# @option options [offset] :offset A cursor used for pagination. offset is an object identifier that defines a place in the list.
|
60
|
-
# @return [
|
60
|
+
# @return [Kongkit::Client::Resource] Plugin Objects
|
61
61
|
def api_plugins(api_identifier, options = {})
|
62
62
|
get(api_plugins_path(api_identifier), options)
|
63
63
|
end
|
@@ -69,7 +69,7 @@ module Kongkit
|
|
69
69
|
# @option attributes [String] :name The name of the Plugin that's going to be added.
|
70
70
|
# @option attributes [String] :consumer_id The unique identifier of the consumer that overrides the existing settings for this specific consumer on incoming requests (optional)
|
71
71
|
# @option attributes [String] :config.{property} The configuration properties for the Plugin.
|
72
|
-
# @return [
|
72
|
+
# @return [Kongkit::Client::Resource] Plugin Object
|
73
73
|
def add_plugin(api_identifier, attributes)
|
74
74
|
post(api_plugins_path(api_identifier), body: attributes)
|
75
75
|
end
|
@@ -82,7 +82,7 @@ module Kongkit
|
|
82
82
|
# @option attributes [String] :name The name of the Plugin that's going to be added.
|
83
83
|
# @option attributes [String] :consumer_id The unique identifier of the consumer that overrides the existing settings for this specific consumer on incoming requests (optional)
|
84
84
|
# @option attributes [String] :config.{property} The configuration properties for the Plugin.
|
85
|
-
# @return [
|
85
|
+
# @return [Kongkit::Client::Resource] Plugin Object
|
86
86
|
def edit_plugin(api_identifier, id, attributes)
|
87
87
|
patch(api_plugin_path(api_identifier, id), body: attributes)
|
88
88
|
end
|
@@ -48,6 +48,13 @@ module Kongkit
|
|
48
48
|
status_code >= 400
|
49
49
|
end
|
50
50
|
|
51
|
+
# Return the JSON representation of the resource
|
52
|
+
#
|
53
|
+
# @return [Hash] JSON representation
|
54
|
+
def to_json
|
55
|
+
data.merge({status_code: status_code})
|
56
|
+
end
|
57
|
+
|
51
58
|
private
|
52
59
|
|
53
60
|
attr_reader :client, :data, :status_code
|
data/lib/kongkit/client.rb
CHANGED
@@ -4,6 +4,7 @@ require 'json'
|
|
4
4
|
require 'kongkit/client/api_object'
|
5
5
|
require 'kongkit/client/cluster'
|
6
6
|
require 'kongkit/client/consumer'
|
7
|
+
require 'kongkit/client/key_authentication'
|
7
8
|
require 'kongkit/client/plugin_object'
|
8
9
|
require 'kongkit/client/node'
|
9
10
|
require 'kongkit/client/request'
|
@@ -16,6 +17,7 @@ module Kongkit
|
|
16
17
|
include ApiObject
|
17
18
|
include Cluster
|
18
19
|
include Consumer
|
20
|
+
include KeyAuthentication
|
19
21
|
include PluginObject
|
20
22
|
include Node
|
21
23
|
include Request
|
data/lib/kongkit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kongkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabian Mettler
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/kongkit/client/api_object.rb
|
145
145
|
- lib/kongkit/client/cluster.rb
|
146
146
|
- lib/kongkit/client/consumer.rb
|
147
|
+
- lib/kongkit/client/key_authentication.rb
|
147
148
|
- lib/kongkit/client/node.rb
|
148
149
|
- lib/kongkit/client/plugin_object.rb
|
149
150
|
- lib/kongkit/client/request.rb
|