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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27a07fb91dbdac22f631ed9bca8c944cd2284b33
4
- data.tar.gz: fc36610fb68f67d070ad0643bf3f3989f930ba30
3
+ metadata.gz: 21a9625c262f22f83140da50758d765ca8f12f7a
4
+ data.tar.gz: 5ca591d272826074cc520e911665ded42fc54ef7
5
5
  SHA512:
6
- metadata.gz: 192a2966df0a1aaf62f6a79c2baee1e1a47c8548e117af52680126e42ba7a11fdac78d6050734ca0b3b45b9ed0bc6debc748d6d5176446a771ae52a3ae77e615
7
- data.tar.gz: dcad30e65b60ba31e435973952bc1587f5b0a962888a0c6080c803b969c1b281b214c07adf94bdd3ccc3a1430722913883a05286f976e6cfc7298340bfa7f557
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 [Hash] API Objects
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 [Hash] API Object
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 [Hash] API Object
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 [Hash] API Object
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 [Hash] Cluster status
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 [Hash] API Objects
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 [Hash] Consumer
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 [Hash] Consumer
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 [Hash] Consumer
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
@@ -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 [Hash] Node information
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 [Hash] Node status
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 [Hash] Plugin Objects
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 [Hash] Plugin Objects
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 [Hash] Plugin Objects
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 [Hash] Plugin Object
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 [Hash] Plugin Objects
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 [Hash] Plugin Object
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 [Hash] Plugin Object
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Kongkit
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.1
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