diff --git a/docs/Api/DefaultApi.md b/docs/Api/DefaultApi.md index ba5d1b1..114b2ee 100644 --- a/docs/Api/DefaultApi.md +++ b/docs/Api/DefaultApi.md @@ -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 +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 diff --git a/docs/Model/Plugin.md b/docs/Model/Plugin.md new file mode 100644 index 0000000..68ba94b --- /dev/null +++ b/docs/Model/Plugin.md @@ -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) diff --git a/src/Api/DefaultApi.php b/src/Api/DefaultApi.php index 98be3b0..614d07b 100644 --- a/src/Api/DefaultApi.php +++ b/src/Api/DefaultApi.php @@ -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. * diff --git a/src/Model/Plugin.php b/src/Model/Plugin.php new file mode 100644 index 0000000..ea0a2a4 --- /dev/null +++ b/src/Model/Plugin.php @@ -0,0 +1,348 @@ + + * @template TKey int|null + * @template TValue mixed|null + */ +class Plugin implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'Plugin'; + + /** + * Array of property to type mappings. Used for (de)serialization. + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'version' => 'string', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization. + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'version' => null, + ]; + + /** + * Array of property to type mappings. Used for (de)serialization. + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization. + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name. + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'version' => 'version', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses). + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'version' => 'setVersion', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests). + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'version' => 'getVersion', + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name. + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses). + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests). + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + /** + * Associative array for storing property values. + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor. + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['name'] = $data['name'] ?? null; + $this->container['version'] = $data['version'] ?? null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed. + * + * @return bool True if all properties are valid + */ + public function valid() + { + return 0 === \count($this->listInvalidProperties()); + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name. + * + * @param string|null $name name + * + * @return self + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets version. + * + * @return string|null + */ + public function getVersion() + { + return $this->container['version']; + } + + /** + * Sets version. + * + * @param string|null $version version + * + * @return self + */ + public function setVersion($version) + { + $this->container['version'] = $version; + + return $this; + } + + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (null === $offset) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param int $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * + * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource + */ + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object. + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + \JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object. + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +}