Skip to content

Commit

Permalink
Support plugins endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
NikoGrano committed Aug 4, 2021
1 parent 9d836f3 commit 3b98d32
Show file tree
Hide file tree
Showing 4 changed files with 650 additions and 0 deletions.
62 changes: 62 additions & 0 deletions docs/Api/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,68 @@ void (empty response body)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)

## `apiPluginsGet()`

```php
apiPluginsGet(): \Fiteco\KimaiClient\Model\Plugin[]
```

Returns information about installed Plugins

### Example

```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: apiToken
$config = Fiteco\KimaiClient\Configuration::getDefaultConfiguration()->setApiKey('X-AUTH-TOKEN', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Fiteco\KimaiClient\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-AUTH-TOKEN', 'Bearer');

// Configure API key authorization: apiUser
$config = Fiteco\KimaiClient\Configuration::getDefaultConfiguration()->setApiKey('X-AUTH-USER', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Fiteco\KimaiClient\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-AUTH-USER', 'Bearer');


$apiInstance = new Fiteco\KimaiClient\Api\DefaultApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);

try {
$result = $apiInstance->apiPluginsGet();
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DefaultApi->apiPluginsGet: ', $e->getMessage(), PHP_EOL;
}
```

### Parameters

This endpoint does not need any parameter.

### Return type

[**\Fiteco\KimaiClient\Model\Plugin[]**](../Model/Plugin.md)

### Authorization

[apiToken](../../README.md#apiToken), [apiUser](../../README.md#apiUser)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: `*/*`

[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)

## `apiVersionGet()`

```php
Expand Down
10 changes: 10 additions & 0 deletions docs/Model/Plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# # Plugin

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **string** | | [optional]
**version** | **string** | | [optional]

[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
230 changes: 230 additions & 0 deletions src/Api/DefaultApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,236 @@ public function apiPingGetRequest()
);
}

/**
* Operation apiPluginsGet.
*
* Returns information about installed Plugins
*
* @throws \Fiteco\KimaiClient\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return \Fiteco\KimaiClient\Model\Plugin[]
*/
public function apiPluginsGet()
{
[$response] = $this->apiPluginsGetWithHttpInfo();

return $response;
}

/**
* Operation apiPluginsGetWithHttpInfo.
*
* Returns information about installed Plugins
*
* @throws \Fiteco\KimaiClient\ApiException on non-2xx response
* @throws \InvalidArgumentException
*
* @return array of \Fiteco\KimaiClient\Model\Plugin[], HTTP status code, HTTP response headers (array of strings)
*/
public function apiPluginsGetWithHttpInfo()
{
$request = $this->apiPluginsGetRequest();

try {
$options = $this->createHttpClientOption();

try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null);
}

$statusCode = $response->getStatusCode();

if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, (string) $request->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}

switch ($statusCode) {
case 200:
if ('\Fiteco\KimaiClient\Model\Plugin[]' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}

return [
ObjectSerializer::deserialize($content, '\Fiteco\KimaiClient\Model\Plugin[]', []),
$response->getStatusCode(),
$response->getHeaders(),
];
}

$returnType = '\Fiteco\KimaiClient\Model\Plugin[]';
if ('\SplFileObject' === $returnType) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}

return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Fiteco\KimaiClient\Model\Plugin[]',
$e->getResponseHeaders()
);
$e->setResponseObject($data);

break;
}

throw $e;
}
}

/**
* Operation apiPluginsGetAsync.
*
* Returns information about installed Plugins
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function apiPluginsGetAsync()
{
return $this->apiPluginsGetAsyncWithHttpInfo()
->then(
function ($response) {
return $response[0];
}
);
}

/**
* Operation apiPluginsGetAsyncWithHttpInfo.
*
* Returns information about installed Plugins
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function apiPluginsGetAsyncWithHttpInfo()
{
$returnType = '\Fiteco\KimaiClient\Model\Plugin[]';
$request = $this->apiPluginsGetRequest();

return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ('\SplFileObject' === $returnType) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}

return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders(),
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();

throw new ApiException(sprintf('[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri()), $statusCode, $response->getHeaders(), (string) $response->getBody());
}
);
}

/**
* Create request for operation 'apiPluginsGet'.
*
* @throws \InvalidArgumentException
*
* @return \GuzzleHttp\Psr7\Request
*/
public function apiPluginsGetRequest()
{
$resourcePath = '/api/plugins';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;

if ($multipart) {
$headers = $this->headerSelector->selectHeadersForMultipart(
['*/*']
);
} else {
$headers = $this->headerSelector->selectHeaders(
['*/*'],
[]
);
}

// for model (json/xml)
if (\count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = \is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem,
];
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif ('application/json' === $headers['Content-Type']) {
$httpBody = \GuzzleHttp\json_encode($formParams);
} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
}
}

// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('X-AUTH-TOKEN');
if (null !== $apiKey) {
$headers['X-AUTH-TOKEN'] = $apiKey;
}
// this endpoint requires API key authentication
$apiKey = $this->config->getApiKeyWithPrefix('X-AUTH-USER');
if (null !== $apiKey) {
$headers['X-AUTH-USER'] = $apiKey;
}

$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}

$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);

$query = \GuzzleHttp\Psr7\build_query($queryParams);

return new Request(
'GET',
$this->config->getHost().$resourcePath.($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}

/**
* Operation apiVersionGet.
*
Expand Down
Loading

0 comments on commit 3b98d32

Please sign in to comment.