Skip to content

Commit

Permalink
Merge pull request #6 from therealgambo/0.13.x
Browse files Browse the repository at this point in the history
Update for 0.13.x release
  • Loading branch information
therealgambo authored May 8, 2018
2 parents 657081d + 0b5a7e9 commit 555b3a0
Show file tree
Hide file tree
Showing 12 changed files with 391 additions and 101 deletions.
17 changes: 11 additions & 6 deletions src/Kong/Apis/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace TheRealGambo\Kong\Apis;

/**
* Class Api
* @package TheRealGambo\Kong\Apis
* @deprecated https://getkong.org/docs/0.13.x/admin-api/#api-object
*/
final class Api extends AbstractApi implements ApiInterface
{
/**
Expand All @@ -16,7 +21,7 @@ final class Api extends AbstractApi implements ApiInterface
/**
* Add an API to Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#add-api
* @see https://getkong.org/docs/0.13.x/admin-api/#add-api
*
* @param array $body
* @param array $headers
Expand All @@ -34,7 +39,7 @@ public function add(array $body = [], array $headers = [])
/**
* Delete an API endpoint from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#delete-api
* @see https://getkong.org/docs/0.13.x/admin-api/#delete-api
*
* @param string $identifier
* @param array $headers
Expand All @@ -49,7 +54,7 @@ public function delete($identifier, array $headers = [])
/**
* Retrieve information about a specific API from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#retrieve-api
* @see https://getkong.org/docs/0.13.x/admin-api/#retrieve-api
*
* @param string $identifier
* @param array $params
Expand All @@ -65,7 +70,7 @@ public function get($identifier, array $params = [], array $headers = [])
/**
* List all API's in Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#list-apis
* @see https://getkong.org/docs/0.13.x/admin-api/#list-apis
*
* @param array $params
* @param array $headers
Expand All @@ -80,7 +85,7 @@ public function list(array $params = [], array $headers = [])
/**
* Update an API on Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#update-api
* @see https://getkong.org/docs/0.13.x/admin-api/#update-api
*
* @param string $identifier
* @param array $body
Expand All @@ -99,7 +104,7 @@ public function update($identifier, array $body = [], array $headers = [])
/**
* Update or Create an API on Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#update-or-create-api
* @see https://getkong.org/docs/0.13.x/admin-api/#update-or-create-api
*
* @param array $body
* @param array $headers
Expand Down
12 changes: 6 additions & 6 deletions src/Kong/Apis/Certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class Certificate extends AbstractApi implements CertificateInterface
/**
* Add a new certificate to Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#add-certificate
* @see https://getkong.org/docs/0.13.x/admin-api/#add-certificate
*
* @param array $body
* @param array $headers
Expand All @@ -32,7 +32,7 @@ public function add(array $body = [], array $headers = [])
/**
* Delete a specific certificate from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#delete-certificate
* @see https://getkong.org/docs/0.13.x/admin-api/#delete-certificate
*
* @param string $identifier
* @param array $headers
Expand All @@ -47,7 +47,7 @@ public function delete($identifier, array $headers = [])
/**
* Retrieve a specific certificate from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#retrieve-certificate
* @see https://getkong.org/docs/0.13.x/admin-api/#retrieve-certificate
*
* @param string $identifier
* @param array $params
Expand All @@ -63,7 +63,7 @@ public function get($identifier, array $params = [], array $headers = [])
/**
* Retrieve all certificates from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#list-certificates
* @see https://getkong.org/docs/0.13.x/admin-api/#list-certificates
*
* @param array $params
* @param array $headers
Expand All @@ -78,7 +78,7 @@ public function list(array $params = [], array $headers = [])
/**
* Update a certificate on Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#update-certificate
* @see https://getkong.org/docs/0.13.x/admin-api/#update-certificate
*
* @param string $identifier
* @param array $body
Expand All @@ -97,7 +97,7 @@ public function update($identifier, array $body = [], array $headers = [])
/**
* Update or Create a certificate on Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#update-or-create-certificate
* @see https://getkong.org/docs/0.13.x/admin-api/#update-or-create-certificate
*
* @param array $body
* @param array $headers
Expand Down
12 changes: 6 additions & 6 deletions src/Kong/Apis/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class Consumer extends AbstractApi implements ConsumerInterface
/**
* Create a new consumer in Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#create-consumer
* @see https://getkong.org/docs/0.13.x/admin-api/#create-consumer
*
* @param array $body
* @param array $headers
Expand All @@ -32,7 +32,7 @@ public function add(array $body = [], array $headers = [])
/**
* Delete a consumer from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#delete-consumer
* @see https://getkong.org/docs/0.13.x/admin-api/#delete-consumer
*
* @param string $identifier
* @param array $headers
Expand All @@ -47,7 +47,7 @@ public function delete($identifier, array $headers = [])
/**
* Retrieve information about a consumer from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#retrieve-consumer
* @see https://getkong.org/docs/0.13.x/admin-api/#retrieve-consumer
*
* @param string $identifier
* @param array $params
Expand Down Expand Up @@ -80,7 +80,7 @@ public function getConsumerPlugin($identifier, $plugin_identifier, array $params
/**
* Retrieve all consumers from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#list-consumers
* @see https://getkong.org/docs/0.13.x/admin-api/#list-consumers
*
* @param array $params
* @param array $headers
Expand Down Expand Up @@ -111,7 +111,7 @@ public function listConsumerPlugins($identifier, array $params = [], array $head
/**
* Update a consumer in Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#update-consumer
* @see https://getkong.org/docs/0.13.x/admin-api/#update-consumer
*
* @param string $identifier
* @param array $body
Expand All @@ -130,7 +130,7 @@ public function update($identifier, array $body = [], array $headers = [])
/**
* Update or Create a consumer in Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#update-or-create-consumer
* @see https://getkong.org/docs/0.13.x/admin-api/#update-or-create-consumer
*
* @param array $body
* @param array $headers
Expand Down
61 changes: 14 additions & 47 deletions src/Kong/Apis/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,17 @@ final class Plugin extends AbstractApi implements PluginInterface
*/
private $pluginAllowedOptions = ['name', 'consumer_id'];

/**
* Add a plugin to an API on Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#add-plugin
*
* @param string $api_identifier
* @param array $body
* @param array $headers
*
* @return array|\stdClass
*/
public function add($api_identifier, array $body = [], array $headers = [])
{
$this->setAllowedOptions($this->pluginAllowedOptions);
$body = $this->createRequestBody($body);

return $this->postRequest('apis/' . $api_identifier . '/plugins', $body, $headers);
}

/**
* Add a plugin globally to every API on Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#add-plugin
* @see https://getkong.org/docs/0.13.x/admin-api/#add-plugin
*
* @param array $body
* @param array $headers
*
* @return array|\stdClass
*/
public function addGlobalPlugin(array $body = [], array $headers = [])
public function add(array $body = [], array $headers = [])
{
$this->setAllowedOptions($this->pluginAllowedOptions);
$body = $this->createRequestBody($body);
Expand All @@ -51,7 +32,7 @@ public function addGlobalPlugin(array $body = [], array $headers = [])
/**
* Remove a plugin from an API
*
* @see https://getkong.org/docs/0.10.x/admin-api/#delete-plugin
* @see https://getkong.org/docs/0.13.x/admin-api/#delete-plugin
*
* @param string $api_identifier
* @param string $identifier
Expand All @@ -67,7 +48,7 @@ public function delete($api_identifier, $identifier, array $headers = [])
/**
* Retrieve information about a specific plugin from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#retrieve-plugin
* @see https://getkong.org/docs/0.13.x/admin-api/#retrieve-plugin
*
* @param string $identifier
* @param array $params
Expand All @@ -83,36 +64,38 @@ public function get($identifier, array $params = [], array $headers = [])
/**
* Retrieve all available plugins from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#retrieve-enabled-plugins
* @see https://getkong.org/docs/0.13.x/admin-api/#retrieve-enabled-plugins
*
* @param array $params
* @param array $headers
*
* @return array|\stdClass
*/
public function getAllAvailable(array $headers = [])
public function getEnabledPlugins(array $params = [], array $headers = [])
{
return $this->getRequest('/plugins/enabled', [], $headers);
return $this->getRequest('/plugins/enabled', $params, $headers);
}

/**
* Retrieve the schema for a specific plugin from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#retrieve-plugin-schema
* @see https://getkong.org/docs/0.13.x/admin-api/#retrieve-plugin-schema
*
* @param string $identifier
* @param array $params
* @param array $headers
*
* @return array|\stdClass
*/
public function getPluginSchema($identifier, array $headers = [])
public function getPluginSchema($identifier, array $params = [], array $headers = [])
{
return $this->getRequest('plugins/schema/' . $identifier, [], $headers);
}

/**
* Retrieve all plugins configured from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#list-all-plugins
* @see https://getkong.org/docs/0.13.x/admin-api/#list-all-plugins
*
* @param array $params
* @param array $headers
Expand All @@ -124,26 +107,10 @@ public function list(array $params = [], array $headers = [])
return $this->getRequest('plugins', $params, $headers);
}

/**
* Retrieve all plugins configured for a specific API from Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#list-plugins-per-api
*
* @param string $api_identifier
* @param array $params
* @param array $headers
*
* @return array|\stdClass
*/
public function listAllPerApi($api_identifier, array $params = [], array $headers = [])
{
return $this->getRequest('apis/' . $api_identifier . '/plugins', $params, $headers);
}

/**
* Update a plugins configuration on Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#update-plugin
* @see https://getkong.org/docs/0.13.x/admin-api/#update-plugin
*
* @param string $api_identifier
* @param string $identifier
Expand All @@ -163,7 +130,7 @@ public function update($api_identifier, $identifier, array $body = [], array $he
/**
* Update or create a plugin on Kong
*
* @see https://getkong.org/docs/0.10.x/admin-api/#update-or-add-plugin
* @see https://getkong.org/docs/0.13.x/admin-api/#update-or-add-plugin
*
* @param string $api_identifier
* @param array $body
Expand Down
8 changes: 3 additions & 5 deletions src/Kong/Apis/PluginInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

interface PluginInterface
{
public function add($api_identifier, array $body = [], array $headers = []);
public function addGlobalPlugin(array $body = [], array $headers = []);
public function add(array $body = [], array $headers = []);
public function delete($api_identifier, $identifier, array $headers = []);
public function get($identifier, array $params = [], array $headers = []);
public function getAllAvailable(array $headers = []);
public function getPluginSchema($identifier, array $headers = []);
public function getEnabledPlugins(array $params = [], array $headers = []);
public function getPluginSchema($identifier, array $params = [], array $headers = []);
public function list(array $params = [], array $headers = []);
public function listAllPerApi($api_identifier, array $params = [], array $headers = []);
public function update($api_identifier, $identifier, array $body = [], array $headers = []);
public function updateOrAdd($api_identifier, array $body = [], array $headers = []);
}
Loading

0 comments on commit 555b3a0

Please sign in to comment.