diff --git a/api/src/API/DatabaseBackupApi.php b/api/src/API/DatabaseBackupApi.php index 260649f..8204ce7 100644 --- a/api/src/API/DatabaseBackupApi.php +++ b/api/src/API/DatabaseBackupApi.php @@ -476,7 +476,7 @@ public function createDatabaseBackupRequest($databaseName, $branchName, string $ * * @throws \Litebase\OpenAPI\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return \Litebase\OpenAPI\Model\DeleteDatabaseBackup200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse + * @return \Litebase\OpenAPI\Model\DeleteDatabaseBackup200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse */ public function deleteDatabaseBackup($databaseName, $branchName, $timestamp, string $contentType = self::contentTypes['deleteDatabaseBackup'][0]) { @@ -496,7 +496,7 @@ public function deleteDatabaseBackup($databaseName, $branchName, $timestamp, str * * @throws \Litebase\OpenAPI\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of \Litebase\OpenAPI\Model\DeleteDatabaseBackup200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \Litebase\OpenAPI\Model\DeleteDatabaseBackup200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse, HTTP status code, HTTP response headers (array of strings) */ public function deleteDatabaseBackupWithHttpInfo($databaseName, $branchName, $timestamp, string $contentType = self::contentTypes['deleteDatabaseBackup'][0]) { @@ -532,6 +532,12 @@ public function deleteDatabaseBackupWithHttpInfo($databaseName, $branchName, $ti $request, $response, ); + case 400: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\ErrorResponse', + $request, + $response, + ); case 403: return $this->handleResponseWithDataType( '\Litebase\OpenAPI\Model\ErrorResponse', @@ -582,6 +588,14 @@ public function deleteDatabaseBackupWithHttpInfo($databaseName, $branchName, $ti ); $e->setResponseObject($data); throw $e; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\ErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; case 403: $data = ObjectSerializer::deserialize( $e->getResponseBody(), diff --git a/api/src/API/DatabaseBranchSettingsApi.php b/api/src/API/DatabaseBranchSettingsApi.php new file mode 100644 index 0000000..58f5392 --- /dev/null +++ b/api/src/API/DatabaseBranchSettingsApi.php @@ -0,0 +1,906 @@ + [ + 'application/json', + ], + 'updateDatabaseBranchSettings' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getDatabaseBranchSettings + * + * Show details of a specific database branch settings + * + * @param string $databaseName The databaseName parameter (required) + * @param string $branchName The branchName parameter (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDatabaseBranchSettings'] to see the possible values for this operation + * + * @throws \Litebase\OpenAPI\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \Litebase\OpenAPI\Model\GetDatabaseBranchSettings200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse + */ + public function getDatabaseBranchSettings($databaseName, $branchName, string $contentType = self::contentTypes['getDatabaseBranchSettings'][0]) + { + list($response) = $this->getDatabaseBranchSettingsWithHttpInfo($databaseName, $branchName, $contentType); + return $response; + } + + /** + * Operation getDatabaseBranchSettingsWithHttpInfo + * + * Show details of a specific database branch settings + * + * @param string $databaseName The databaseName parameter (required) + * @param string $branchName The branchName parameter (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDatabaseBranchSettings'] to see the possible values for this operation + * + * @throws \Litebase\OpenAPI\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \Litebase\OpenAPI\Model\GetDatabaseBranchSettings200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getDatabaseBranchSettingsWithHttpInfo($databaseName, $branchName, string $contentType = self::contentTypes['getDatabaseBranchSettings'][0]) + { + $request = $this->getDatabaseBranchSettingsRequest($databaseName, $branchName, $contentType); + + 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 + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\GetDatabaseBranchSettings200Response', + $request, + $response, + ); + case 400: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\ErrorResponse', + $request, + $response, + ); + case 403: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\ErrorResponse', + $request, + $response, + ); + case 404: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\ErrorResponse', + $request, + $response, + ); + case 500: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\ErrorResponse', + $request, + $response, + ); + } + + + + 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() + ); + } + + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\GetDatabaseBranchSettings200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\GetDatabaseBranchSettings200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\ErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\ErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\ErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\ErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation getDatabaseBranchSettingsAsync + * + * Show details of a specific database branch settings + * + * @param string $databaseName The databaseName parameter (required) + * @param string $branchName The branchName parameter (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDatabaseBranchSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDatabaseBranchSettingsAsync($databaseName, $branchName, string $contentType = self::contentTypes['getDatabaseBranchSettings'][0]) + { + return $this->getDatabaseBranchSettingsAsyncWithHttpInfo($databaseName, $branchName, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getDatabaseBranchSettingsAsyncWithHttpInfo + * + * Show details of a specific database branch settings + * + * @param string $databaseName The databaseName parameter (required) + * @param string $branchName The branchName parameter (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDatabaseBranchSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDatabaseBranchSettingsAsyncWithHttpInfo($databaseName, $branchName, string $contentType = self::contentTypes['getDatabaseBranchSettings'][0]) + { + $returnType = '\Litebase\OpenAPI\Model\GetDatabaseBranchSettings200Response'; + $request = $this->getDatabaseBranchSettingsRequest($databaseName, $branchName, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + 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 'getDatabaseBranchSettings' + * + * @param string $databaseName The databaseName parameter (required) + * @param string $branchName The branchName parameter (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDatabaseBranchSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getDatabaseBranchSettingsRequest($databaseName, $branchName, string $contentType = self::contentTypes['getDatabaseBranchSettings'][0]) + { + + // verify the required parameter 'databaseName' is set + if ($databaseName === null || (is_array($databaseName) && count($databaseName) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $databaseName when calling getDatabaseBranchSettings' + ); + } + + // verify the required parameter 'branchName' is set + if ($branchName === null || (is_array($branchName) && count($branchName) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $branchName when calling getDatabaseBranchSettings' + ); + } + + + $resourcePath = '/v1/databases/{databaseName}/branches/{branchName}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($databaseName !== null) { + $resourcePath = str_replace( + '{' . 'databaseName' . '}', + ObjectSerializer::toPathValue($databaseName), + $resourcePath + ); + } + // path params + if ($branchName !== null) { + $resourcePath = str_replace( + '{' . 'branchName' . '}', + ObjectSerializer::toPathValue($branchName), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // 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 (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + // this endpoint requires Bearer authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateDatabaseBranchSettings + * + * Update an existing database branch settings + * + * @param string $databaseName The databaseName parameter (required) + * @param string $branchName The branchName parameter (required) + * @param \Litebase\OpenAPI\Model\DatabaseBranchSettingsUpdateRequest $databaseBranchSettingsUpdateRequest Database branch setting update data (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDatabaseBranchSettings'] to see the possible values for this operation + * + * @throws \Litebase\OpenAPI\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \Litebase\OpenAPI\Model\UpdateDatabaseBranchSettings200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ValidationErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse + */ + public function updateDatabaseBranchSettings($databaseName, $branchName, $databaseBranchSettingsUpdateRequest, string $contentType = self::contentTypes['updateDatabaseBranchSettings'][0]) + { + list($response) = $this->updateDatabaseBranchSettingsWithHttpInfo($databaseName, $branchName, $databaseBranchSettingsUpdateRequest, $contentType); + return $response; + } + + /** + * Operation updateDatabaseBranchSettingsWithHttpInfo + * + * Update an existing database branch settings + * + * @param string $databaseName The databaseName parameter (required) + * @param string $branchName The branchName parameter (required) + * @param \Litebase\OpenAPI\Model\DatabaseBranchSettingsUpdateRequest $databaseBranchSettingsUpdateRequest Database branch setting update data (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDatabaseBranchSettings'] to see the possible values for this operation + * + * @throws \Litebase\OpenAPI\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \Litebase\OpenAPI\Model\UpdateDatabaseBranchSettings200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ValidationErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateDatabaseBranchSettingsWithHttpInfo($databaseName, $branchName, $databaseBranchSettingsUpdateRequest, string $contentType = self::contentTypes['updateDatabaseBranchSettings'][0]) + { + $request = $this->updateDatabaseBranchSettingsRequest($databaseName, $branchName, $databaseBranchSettingsUpdateRequest, $contentType); + + 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 + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\UpdateDatabaseBranchSettings200Response', + $request, + $response, + ); + case 400: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\ErrorResponse', + $request, + $response, + ); + case 403: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\ErrorResponse', + $request, + $response, + ); + case 404: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\ErrorResponse', + $request, + $response, + ); + case 422: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\ValidationErrorResponse', + $request, + $response, + ); + case 500: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\ErrorResponse', + $request, + $response, + ); + } + + + + 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() + ); + } + + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\UpdateDatabaseBranchSettings200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\UpdateDatabaseBranchSettings200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\ErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\ErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\ErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 422: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\ValidationErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\ErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation updateDatabaseBranchSettingsAsync + * + * Update an existing database branch settings + * + * @param string $databaseName The databaseName parameter (required) + * @param string $branchName The branchName parameter (required) + * @param \Litebase\OpenAPI\Model\DatabaseBranchSettingsUpdateRequest $databaseBranchSettingsUpdateRequest Database branch setting update data (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDatabaseBranchSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateDatabaseBranchSettingsAsync($databaseName, $branchName, $databaseBranchSettingsUpdateRequest, string $contentType = self::contentTypes['updateDatabaseBranchSettings'][0]) + { + return $this->updateDatabaseBranchSettingsAsyncWithHttpInfo($databaseName, $branchName, $databaseBranchSettingsUpdateRequest, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateDatabaseBranchSettingsAsyncWithHttpInfo + * + * Update an existing database branch settings + * + * @param string $databaseName The databaseName parameter (required) + * @param string $branchName The branchName parameter (required) + * @param \Litebase\OpenAPI\Model\DatabaseBranchSettingsUpdateRequest $databaseBranchSettingsUpdateRequest Database branch setting update data (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDatabaseBranchSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateDatabaseBranchSettingsAsyncWithHttpInfo($databaseName, $branchName, $databaseBranchSettingsUpdateRequest, string $contentType = self::contentTypes['updateDatabaseBranchSettings'][0]) + { + $returnType = '\Litebase\OpenAPI\Model\UpdateDatabaseBranchSettings200Response'; + $request = $this->updateDatabaseBranchSettingsRequest($databaseName, $branchName, $databaseBranchSettingsUpdateRequest, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + 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 'updateDatabaseBranchSettings' + * + * @param string $databaseName The databaseName parameter (required) + * @param string $branchName The branchName parameter (required) + * @param \Litebase\OpenAPI\Model\DatabaseBranchSettingsUpdateRequest $databaseBranchSettingsUpdateRequest Database branch setting update data (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateDatabaseBranchSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateDatabaseBranchSettingsRequest($databaseName, $branchName, $databaseBranchSettingsUpdateRequest, string $contentType = self::contentTypes['updateDatabaseBranchSettings'][0]) + { + + // verify the required parameter 'databaseName' is set + if ($databaseName === null || (is_array($databaseName) && count($databaseName) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $databaseName when calling updateDatabaseBranchSettings' + ); + } + + // verify the required parameter 'branchName' is set + if ($branchName === null || (is_array($branchName) && count($branchName) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $branchName when calling updateDatabaseBranchSettings' + ); + } + + // verify the required parameter 'databaseBranchSettingsUpdateRequest' is set + if ($databaseBranchSettingsUpdateRequest === null || (is_array($databaseBranchSettingsUpdateRequest) && count($databaseBranchSettingsUpdateRequest) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $databaseBranchSettingsUpdateRequest when calling updateDatabaseBranchSettings' + ); + } + + + $resourcePath = '/v1/databases/{databaseName}/branches/{branchName}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($databaseName !== null) { + $resourcePath = str_replace( + '{' . 'databaseName' . '}', + ObjectSerializer::toPathValue($databaseName), + $resourcePath + ); + } + // path params + if ($branchName !== null) { + $resourcePath = str_replace( + '{' . 'branchName' . '}', + ObjectSerializer::toPathValue($branchName), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($databaseBranchSettingsUpdateRequest)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($databaseBranchSettingsUpdateRequest)); + } else { + $httpBody = $databaseBranchSettingsUpdateRequest; + } + } elseif (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 (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + // this endpoint requires Bearer authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } + + private function handleResponseWithDataType( + string $dataType, + RequestInterface $request, + ResponseInterface $response + ): array { + if ($dataType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($dataType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $response->getStatusCode(), + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $dataType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + private function responseWithinRangeCode( + string $rangeCode, + int $statusCode + ): bool { + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); + + return $statusCode >= $left && $statusCode <= $right; + } +} diff --git a/api/src/API/DatabaseExportApi.php b/api/src/API/DatabaseExportApi.php index 6b8c74b..aba9f9f 100644 --- a/api/src/API/DatabaseExportApi.php +++ b/api/src/API/DatabaseExportApi.php @@ -116,7 +116,7 @@ public function getConfig() * * @throws \Litebase\OpenAPI\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return \Litebase\OpenAPI\Model\CreateDatabaseExport200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse + * @return \Litebase\OpenAPI\Model\CreateDatabaseExport200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse */ public function createDatabaseExport($databaseName, $branchName, $body, string $contentType = self::contentTypes['createDatabaseExport'][0]) { @@ -136,7 +136,7 @@ public function createDatabaseExport($databaseName, $branchName, $body, string $ * * @throws \Litebase\OpenAPI\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException - * @return array of \Litebase\OpenAPI\Model\CreateDatabaseExport200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @return array of \Litebase\OpenAPI\Model\CreateDatabaseExport200Response|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse|\Litebase\OpenAPI\Model\ErrorResponse, HTTP status code, HTTP response headers (array of strings) */ public function createDatabaseExportWithHttpInfo($databaseName, $branchName, $body, string $contentType = self::contentTypes['createDatabaseExport'][0]) { @@ -172,6 +172,12 @@ public function createDatabaseExportWithHttpInfo($databaseName, $branchName, $bo $request, $response, ); + case 400: + return $this->handleResponseWithDataType( + '\Litebase\OpenAPI\Model\ErrorResponse', + $request, + $response, + ); case 403: return $this->handleResponseWithDataType( '\Litebase\OpenAPI\Model\ErrorResponse', @@ -216,6 +222,14 @@ public function createDatabaseExportWithHttpInfo($databaseName, $branchName, $bo ); $e->setResponseObject($data); throw $e; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Litebase\OpenAPI\Model\ErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; case 403: $data = ObjectSerializer::deserialize( $e->getResponseBody(), diff --git a/api/src/API/DatabaseExportEndApi.php b/api/src/API/DatabaseExportEndApi.php index 0177ecd..0f835ce 100644 --- a/api/src/API/DatabaseExportEndApi.php +++ b/api/src/API/DatabaseExportEndApi.php @@ -1,5 +1,4 @@ getStatusCode(); - switch ($statusCode) { + switch($statusCode) { case 200: return $this->handleResponseWithDataType( - 'object', + '\Litebase\OpenAPI\Model\CreateDatabaseExportEnd200Response', $request, $response, ); @@ -201,7 +200,7 @@ public function createDatabaseExportEndWithHttpInfo($databaseName, $branchName, ); } - + if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( @@ -217,7 +216,7 @@ public function createDatabaseExportEndWithHttpInfo($databaseName, $branchName, } return $this->handleResponseWithDataType( - 'object', + '\Litebase\OpenAPI\Model\CreateDatabaseExportEnd200Response', $request, $response, ); @@ -226,7 +225,7 @@ public function createDatabaseExportEndWithHttpInfo($databaseName, $branchName, case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), - 'object', + '\Litebase\OpenAPI\Model\CreateDatabaseExportEnd200Response', $e->getResponseHeaders() ); $e->setResponseObject($data); @@ -264,7 +263,7 @@ public function createDatabaseExportEndWithHttpInfo($databaseName, $branchName, $e->setResponseObject($data); throw $e; } - + throw $e; } @@ -310,7 +309,7 @@ function ($response) { */ public function createDatabaseExportEndAsyncWithHttpInfo($databaseName, $branchName, $exportId, $body, string $contentType = self::contentTypes['createDatabaseExportEnd'][0]) { - $returnType = 'object'; + $returnType = '\Litebase\OpenAPI\Model\CreateDatabaseExportEnd200Response'; $request = $this->createDatabaseExportEndRequest($databaseName, $branchName, $exportId, $body, $contentType); return $this->client @@ -429,7 +428,7 @@ public function createDatabaseExportEndRequest($databaseName, $branchName, $expo $headers = $this->headerSelector->selectHeaders( - ['application/json',], + ['application/json', ], $contentType, $multipart ); @@ -456,6 +455,7 @@ public function createDatabaseExportEndRequest($databaseName, $branchName, $expo } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); @@ -550,8 +550,8 @@ private function responseWithinRangeCode( string $rangeCode, int $statusCode ): bool { - $left = (int) ($rangeCode[0] . '00'); - $right = (int) ($rangeCode[0] . '99'); + $left = (int) ($rangeCode[0].'00'); + $right = (int) ($rangeCode[0].'99'); return $statusCode >= $left && $statusCode <= $right; } diff --git a/api/src/Model/CreateDatabaseExportEnd200Response.php b/api/src/Model/CreateDatabaseExportEnd200Response.php new file mode 100644 index 0000000..eb199d1 --- /dev/null +++ b/api/src/Model/CreateDatabaseExportEnd200Response.php @@ -0,0 +1,414 @@ + 'string', + 'status' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'message' => null, + 'status' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'message' => false, + 'status' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'message' => 'message', + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'message' => 'setMessage', + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'message' => 'getMessage', + 'status' => 'getStatus' + ]; + + /** + * 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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['message'] === null) { + $invalidProperties[] = "'message' can't be null"; + } + if ($this->container['status'] === null) { + $invalidProperties[] = "'status' can't be null"; + } + 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 count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string $message Response message + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets status + * + * @return string + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string $status Response status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + 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): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link 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. + */ + #[\ReturnTypeWillChange] + 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)); + } +} + + diff --git a/api/src/Model/DatabaseBranchSettingsUpdateRequest.php b/api/src/Model/DatabaseBranchSettingsUpdateRequest.php new file mode 100644 index 0000000..c66431a --- /dev/null +++ b/api/src/Model/DatabaseBranchSettingsUpdateRequest.php @@ -0,0 +1,680 @@ + 'string', + 'backupsEnabled' => 'bool', + 'backupsRetentionDays' => 'int', + 'defaultPragmas' => '\Litebase\OpenAPI\Model\DatabaseDefaultPragmaSettings', + 'errorLogsEnabled' => 'bool', + 'errorLogsRetentionDays' => 'int', + 'incrementalBackupsEnabled' => 'bool', + 'incrementalBackupsRetentionDays' => 'int', + 'queryLogsEnabled' => 'bool', + 'queryLogsRetentionDays' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'backupInterval' => null, + 'backupsEnabled' => null, + 'backupsRetentionDays' => null, + 'defaultPragmas' => null, + 'errorLogsEnabled' => null, + 'errorLogsRetentionDays' => null, + 'incrementalBackupsEnabled' => null, + 'incrementalBackupsRetentionDays' => null, + 'queryLogsEnabled' => null, + 'queryLogsRetentionDays' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'backupInterval' => false, + 'backupsEnabled' => false, + 'backupsRetentionDays' => false, + 'defaultPragmas' => false, + 'errorLogsEnabled' => false, + 'errorLogsRetentionDays' => false, + 'incrementalBackupsEnabled' => false, + 'incrementalBackupsRetentionDays' => false, + 'queryLogsEnabled' => false, + 'queryLogsRetentionDays' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'backupInterval' => 'backupInterval', + 'backupsEnabled' => 'backupsEnabled', + 'backupsRetentionDays' => 'backupsRetentionDays', + 'defaultPragmas' => 'defaultPragmas', + 'errorLogsEnabled' => 'errorLogsEnabled', + 'errorLogsRetentionDays' => 'errorLogsRetentionDays', + 'incrementalBackupsEnabled' => 'incrementalBackupsEnabled', + 'incrementalBackupsRetentionDays' => 'incrementalBackupsRetentionDays', + 'queryLogsEnabled' => 'queryLogsEnabled', + 'queryLogsRetentionDays' => 'queryLogsRetentionDays' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'backupInterval' => 'setBackupInterval', + 'backupsEnabled' => 'setBackupsEnabled', + 'backupsRetentionDays' => 'setBackupsRetentionDays', + 'defaultPragmas' => 'setDefaultPragmas', + 'errorLogsEnabled' => 'setErrorLogsEnabled', + 'errorLogsRetentionDays' => 'setErrorLogsRetentionDays', + 'incrementalBackupsEnabled' => 'setIncrementalBackupsEnabled', + 'incrementalBackupsRetentionDays' => 'setIncrementalBackupsRetentionDays', + 'queryLogsEnabled' => 'setQueryLogsEnabled', + 'queryLogsRetentionDays' => 'setQueryLogsRetentionDays' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'backupInterval' => 'getBackupInterval', + 'backupsEnabled' => 'getBackupsEnabled', + 'backupsRetentionDays' => 'getBackupsRetentionDays', + 'defaultPragmas' => 'getDefaultPragmas', + 'errorLogsEnabled' => 'getErrorLogsEnabled', + 'errorLogsRetentionDays' => 'getErrorLogsRetentionDays', + 'incrementalBackupsEnabled' => 'getIncrementalBackupsEnabled', + 'incrementalBackupsRetentionDays' => 'getIncrementalBackupsRetentionDays', + 'queryLogsEnabled' => 'getQueryLogsEnabled', + 'queryLogsRetentionDays' => 'getQueryLogsRetentionDays' + ]; + + /** + * 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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('backupInterval', $data ?? [], null); + $this->setIfExists('backupsEnabled', $data ?? [], null); + $this->setIfExists('backupsRetentionDays', $data ?? [], null); + $this->setIfExists('defaultPragmas', $data ?? [], null); + $this->setIfExists('errorLogsEnabled', $data ?? [], null); + $this->setIfExists('errorLogsRetentionDays', $data ?? [], null); + $this->setIfExists('incrementalBackupsEnabled', $data ?? [], null); + $this->setIfExists('incrementalBackupsRetentionDays', $data ?? [], null); + $this->setIfExists('queryLogsEnabled', $data ?? [], null); + $this->setIfExists('queryLogsRetentionDays', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * 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 count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets backupInterval + * + * @return string|null + */ + public function getBackupInterval() + { + return $this->container['backupInterval']; + } + + /** + * Sets backupInterval + * + * @param string|null $backupInterval backupInterval + * + * @return self + */ + public function setBackupInterval($backupInterval) + { + if (is_null($backupInterval)) { + throw new \InvalidArgumentException('non-nullable backupInterval cannot be null'); + } + $this->container['backupInterval'] = $backupInterval; + + return $this; + } + + /** + * Gets backupsEnabled + * + * @return bool|null + */ + public function getBackupsEnabled() + { + return $this->container['backupsEnabled']; + } + + /** + * Sets backupsEnabled + * + * @param bool|null $backupsEnabled backupsEnabled + * + * @return self + */ + public function setBackupsEnabled($backupsEnabled) + { + if (is_null($backupsEnabled)) { + throw new \InvalidArgumentException('non-nullable backupsEnabled cannot be null'); + } + $this->container['backupsEnabled'] = $backupsEnabled; + + return $this; + } + + /** + * Gets backupsRetentionDays + * + * @return int|null + */ + public function getBackupsRetentionDays() + { + return $this->container['backupsRetentionDays']; + } + + /** + * Sets backupsRetentionDays + * + * @param int|null $backupsRetentionDays backupsRetentionDays + * + * @return self + */ + public function setBackupsRetentionDays($backupsRetentionDays) + { + if (is_null($backupsRetentionDays)) { + throw new \InvalidArgumentException('non-nullable backupsRetentionDays cannot be null'); + } + $this->container['backupsRetentionDays'] = $backupsRetentionDays; + + return $this; + } + + /** + * Gets defaultPragmas + * + * @return \Litebase\OpenAPI\Model\DatabaseDefaultPragmaSettings|null + */ + public function getDefaultPragmas() + { + return $this->container['defaultPragmas']; + } + + /** + * Sets defaultPragmas + * + * @param \Litebase\OpenAPI\Model\DatabaseDefaultPragmaSettings|null $defaultPragmas defaultPragmas + * + * @return self + */ + public function setDefaultPragmas($defaultPragmas) + { + if (is_null($defaultPragmas)) { + throw new \InvalidArgumentException('non-nullable defaultPragmas cannot be null'); + } + $this->container['defaultPragmas'] = $defaultPragmas; + + return $this; + } + + /** + * Gets errorLogsEnabled + * + * @return bool|null + */ + public function getErrorLogsEnabled() + { + return $this->container['errorLogsEnabled']; + } + + /** + * Sets errorLogsEnabled + * + * @param bool|null $errorLogsEnabled errorLogsEnabled + * + * @return self + */ + public function setErrorLogsEnabled($errorLogsEnabled) + { + if (is_null($errorLogsEnabled)) { + throw new \InvalidArgumentException('non-nullable errorLogsEnabled cannot be null'); + } + $this->container['errorLogsEnabled'] = $errorLogsEnabled; + + return $this; + } + + /** + * Gets errorLogsRetentionDays + * + * @return int|null + */ + public function getErrorLogsRetentionDays() + { + return $this->container['errorLogsRetentionDays']; + } + + /** + * Sets errorLogsRetentionDays + * + * @param int|null $errorLogsRetentionDays errorLogsRetentionDays + * + * @return self + */ + public function setErrorLogsRetentionDays($errorLogsRetentionDays) + { + if (is_null($errorLogsRetentionDays)) { + throw new \InvalidArgumentException('non-nullable errorLogsRetentionDays cannot be null'); + } + $this->container['errorLogsRetentionDays'] = $errorLogsRetentionDays; + + return $this; + } + + /** + * Gets incrementalBackupsEnabled + * + * @return bool|null + */ + public function getIncrementalBackupsEnabled() + { + return $this->container['incrementalBackupsEnabled']; + } + + /** + * Sets incrementalBackupsEnabled + * + * @param bool|null $incrementalBackupsEnabled incrementalBackupsEnabled + * + * @return self + */ + public function setIncrementalBackupsEnabled($incrementalBackupsEnabled) + { + if (is_null($incrementalBackupsEnabled)) { + throw new \InvalidArgumentException('non-nullable incrementalBackupsEnabled cannot be null'); + } + $this->container['incrementalBackupsEnabled'] = $incrementalBackupsEnabled; + + return $this; + } + + /** + * Gets incrementalBackupsRetentionDays + * + * @return int|null + */ + public function getIncrementalBackupsRetentionDays() + { + return $this->container['incrementalBackupsRetentionDays']; + } + + /** + * Sets incrementalBackupsRetentionDays + * + * @param int|null $incrementalBackupsRetentionDays incrementalBackupsRetentionDays + * + * @return self + */ + public function setIncrementalBackupsRetentionDays($incrementalBackupsRetentionDays) + { + if (is_null($incrementalBackupsRetentionDays)) { + throw new \InvalidArgumentException('non-nullable incrementalBackupsRetentionDays cannot be null'); + } + $this->container['incrementalBackupsRetentionDays'] = $incrementalBackupsRetentionDays; + + return $this; + } + + /** + * Gets queryLogsEnabled + * + * @return bool|null + */ + public function getQueryLogsEnabled() + { + return $this->container['queryLogsEnabled']; + } + + /** + * Sets queryLogsEnabled + * + * @param bool|null $queryLogsEnabled queryLogsEnabled + * + * @return self + */ + public function setQueryLogsEnabled($queryLogsEnabled) + { + if (is_null($queryLogsEnabled)) { + throw new \InvalidArgumentException('non-nullable queryLogsEnabled cannot be null'); + } + $this->container['queryLogsEnabled'] = $queryLogsEnabled; + + return $this; + } + + /** + * Gets queryLogsRetentionDays + * + * @return int|null + */ + public function getQueryLogsRetentionDays() + { + return $this->container['queryLogsRetentionDays']; + } + + /** + * Sets queryLogsRetentionDays + * + * @param int|null $queryLogsRetentionDays queryLogsRetentionDays + * + * @return self + */ + public function setQueryLogsRetentionDays($queryLogsRetentionDays) + { + if (is_null($queryLogsRetentionDays)) { + throw new \InvalidArgumentException('non-nullable queryLogsRetentionDays cannot be null'); + } + $this->container['queryLogsRetentionDays'] = $queryLogsRetentionDays; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + 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): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link 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. + */ + #[\ReturnTypeWillChange] + 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)); + } +} + + diff --git a/api/src/Model/DatabaseBranchStoreResponse.php b/api/src/Model/DatabaseBranchStoreResponse.php index 94a6f5d..b031901 100644 --- a/api/src/Model/DatabaseBranchStoreResponse.php +++ b/api/src/Model/DatabaseBranchStoreResponse.php @@ -29,7 +29,6 @@ class DatabaseBranchStoreResponse implements ModelInterface, ArrayAccess, \JsonS 'id' => 'int', 'name' => 'string', 'parentName' => 'string', - 'settings' => '\Litebase\OpenAPI\Model\BranchSettings', 'updatedAt' => '\DateTime' ]; @@ -48,7 +47,6 @@ class DatabaseBranchStoreResponse implements ModelInterface, ArrayAccess, \JsonS 'id' => null, 'name' => null, 'parentName' => null, - 'settings' => null, 'updatedAt' => 'date-time' ]; @@ -65,7 +63,6 @@ class DatabaseBranchStoreResponse implements ModelInterface, ArrayAccess, \JsonS 'id' => false, 'name' => false, 'parentName' => false, - 'settings' => false, 'updatedAt' => false ]; @@ -162,7 +159,6 @@ public function isNullableSetToNull(string $property): bool 'id' => 'id', 'name' => 'name', 'parentName' => 'parentName', - 'settings' => 'settings', 'updatedAt' => 'updatedAt' ]; @@ -179,7 +175,6 @@ public function isNullableSetToNull(string $property): bool 'id' => 'setId', 'name' => 'setName', 'parentName' => 'setParentName', - 'settings' => 'setSettings', 'updatedAt' => 'setUpdatedAt' ]; @@ -196,7 +191,6 @@ public function isNullableSetToNull(string $property): bool 'id' => 'getId', 'name' => 'getName', 'parentName' => 'getParentName', - 'settings' => 'getSettings', 'updatedAt' => 'getUpdatedAt' ]; @@ -264,7 +258,6 @@ public function __construct(?array $data = null) $this->setIfExists('id', $data ?? [], null); $this->setIfExists('name', $data ?? [], null); $this->setIfExists('parentName', $data ?? [], null); - $this->setIfExists('settings', $data ?? [], null); $this->setIfExists('updatedAt', $data ?? [], null); } @@ -499,33 +492,6 @@ public function setParentName($parentName) return $this; } - /** - * Gets settings - * - * @return \Litebase\OpenAPI\Model\BranchSettings|null - */ - public function getSettings() - { - return $this->container['settings']; - } - - /** - * Sets settings - * - * @param \Litebase\OpenAPI\Model\BranchSettings|null $settings settings - * - * @return self - */ - public function setSettings($settings) - { - if (is_null($settings)) { - throw new \InvalidArgumentException('non-nullable settings cannot be null'); - } - $this->container['settings'] = $settings; - - return $this; - } - /** * Gets updatedAt * diff --git a/api/src/Model/DatabaseDefaultPragmaSettings.php b/api/src/Model/DatabaseDefaultPragmaSettings.php new file mode 100644 index 0000000..26db1af --- /dev/null +++ b/api/src/Model/DatabaseDefaultPragmaSettings.php @@ -0,0 +1,411 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'foreignKeys' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'foreignKeys' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'foreignKeys' => 'foreignKeys' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'foreignKeys' => 'setForeignKeys' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'foreignKeys' => 'getForeignKeys' + ]; + + /** + * 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; + } + + public const FOREIGN_KEYS_ON = 'ON'; + public const FOREIGN_KEYS_OFF = 'OFF'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getForeignKeysAllowableValues() + { + return [ + self::FOREIGN_KEYS_ON, + self::FOREIGN_KEYS_OFF, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('foreignKeys', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['foreignKeys'] === null) { + $invalidProperties[] = "'foreignKeys' can't be null"; + } + $allowedValues = $this->getForeignKeysAllowableValues(); + if (!is_null($this->container['foreignKeys']) && !in_array($this->container['foreignKeys'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'foreignKeys', must be one of '%s'", + $this->container['foreignKeys'], + implode("', '", $allowedValues) + ); + } + + 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 count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets foreignKeys + * + * @return string + */ + public function getForeignKeys() + { + return $this->container['foreignKeys']; + } + + /** + * Sets foreignKeys + * + * @param string $foreignKeys foreignKeys + * + * @return self + */ + public function setForeignKeys($foreignKeys) + { + if (is_null($foreignKeys)) { + throw new \InvalidArgumentException('non-nullable foreignKeys cannot be null'); + } + $allowedValues = $this->getForeignKeysAllowableValues(); + if (!in_array($foreignKeys, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'foreignKeys', must be one of '%s'", + $foreignKeys, + implode("', '", $allowedValues) + ) + ); + } + $this->container['foreignKeys'] = $foreignKeys; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + 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): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link 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. + */ + #[\ReturnTypeWillChange] + 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)); + } +} + + diff --git a/api/src/Model/DatabaseResponse.php b/api/src/Model/DatabaseResponse.php index 03c8daa..be2f995 100644 --- a/api/src/Model/DatabaseResponse.php +++ b/api/src/Model/DatabaseResponse.php @@ -27,7 +27,6 @@ class DatabaseResponse implements ModelInterface, ArrayAccess, \JsonSerializable 'databaseId' => 'string', 'databaseName' => 'string', 'id' => 'int', - 'settings' => '\Litebase\OpenAPI\Model\DatabaseSettings', 'updatedAt' => '\DateTime', 'url' => 'string' ]; @@ -45,7 +44,6 @@ class DatabaseResponse implements ModelInterface, ArrayAccess, \JsonSerializable 'databaseId' => null, 'databaseName' => null, 'id' => null, - 'settings' => null, 'updatedAt' => 'date-time', 'url' => null ]; @@ -61,7 +59,6 @@ class DatabaseResponse implements ModelInterface, ArrayAccess, \JsonSerializable 'databaseId' => false, 'databaseName' => false, 'id' => false, - 'settings' => false, 'updatedAt' => false, 'url' => false ]; @@ -157,7 +154,6 @@ public function isNullableSetToNull(string $property): bool 'databaseId' => 'databaseId', 'databaseName' => 'databaseName', 'id' => 'id', - 'settings' => 'settings', 'updatedAt' => 'updatedAt', 'url' => 'url' ]; @@ -173,7 +169,6 @@ public function isNullableSetToNull(string $property): bool 'databaseId' => 'setDatabaseId', 'databaseName' => 'setDatabaseName', 'id' => 'setId', - 'settings' => 'setSettings', 'updatedAt' => 'setUpdatedAt', 'url' => 'setUrl' ]; @@ -189,7 +184,6 @@ public function isNullableSetToNull(string $property): bool 'databaseId' => 'getDatabaseId', 'databaseName' => 'getDatabaseName', 'id' => 'getId', - 'settings' => 'getSettings', 'updatedAt' => 'getUpdatedAt', 'url' => 'getUrl' ]; @@ -256,7 +250,6 @@ public function __construct(?array $data = null) $this->setIfExists('databaseId', $data ?? [], null); $this->setIfExists('databaseName', $data ?? [], null); $this->setIfExists('id', $data ?? [], null); - $this->setIfExists('settings', $data ?? [], null); $this->setIfExists('updatedAt', $data ?? [], null); $this->setIfExists('url', $data ?? [], null); } @@ -438,33 +431,6 @@ public function setId($id) return $this; } - /** - * Gets settings - * - * @return \Litebase\OpenAPI\Model\DatabaseSettings|null - */ - public function getSettings() - { - return $this->container['settings']; - } - - /** - * Sets settings - * - * @param \Litebase\OpenAPI\Model\DatabaseSettings|null $settings settings - * - * @return self - */ - public function setSettings($settings) - { - if (is_null($settings)) { - throw new \InvalidArgumentException('non-nullable settings cannot be null'); - } - $this->container['settings'] = $settings; - - return $this; - } - /** * Gets updatedAt * diff --git a/api/src/Model/DatabaseShowResponse.php b/api/src/Model/DatabaseShowResponse.php index 0b514e3..40c5a9b 100644 --- a/api/src/Model/DatabaseShowResponse.php +++ b/api/src/Model/DatabaseShowResponse.php @@ -27,7 +27,6 @@ class DatabaseShowResponse implements ModelInterface, ArrayAccess, \JsonSerializ 'databaseId' => 'string', 'databaseName' => 'string', 'id' => 'int', - 'settings' => '\Litebase\OpenAPI\Model\DatabaseSettings', 'updatedAt' => '\DateTime', 'url' => 'string' ]; @@ -45,7 +44,6 @@ class DatabaseShowResponse implements ModelInterface, ArrayAccess, \JsonSerializ 'databaseId' => null, 'databaseName' => null, 'id' => null, - 'settings' => null, 'updatedAt' => 'date-time', 'url' => null ]; @@ -61,7 +59,6 @@ class DatabaseShowResponse implements ModelInterface, ArrayAccess, \JsonSerializ 'databaseId' => false, 'databaseName' => false, 'id' => false, - 'settings' => false, 'updatedAt' => false, 'url' => false ]; @@ -157,7 +154,6 @@ public function isNullableSetToNull(string $property): bool 'databaseId' => 'databaseId', 'databaseName' => 'databaseName', 'id' => 'id', - 'settings' => 'settings', 'updatedAt' => 'updatedAt', 'url' => 'url' ]; @@ -173,7 +169,6 @@ public function isNullableSetToNull(string $property): bool 'databaseId' => 'setDatabaseId', 'databaseName' => 'setDatabaseName', 'id' => 'setId', - 'settings' => 'setSettings', 'updatedAt' => 'setUpdatedAt', 'url' => 'setUrl' ]; @@ -189,7 +184,6 @@ public function isNullableSetToNull(string $property): bool 'databaseId' => 'getDatabaseId', 'databaseName' => 'getDatabaseName', 'id' => 'getId', - 'settings' => 'getSettings', 'updatedAt' => 'getUpdatedAt', 'url' => 'getUrl' ]; @@ -256,7 +250,6 @@ public function __construct(?array $data = null) $this->setIfExists('databaseId', $data ?? [], null); $this->setIfExists('databaseName', $data ?? [], null); $this->setIfExists('id', $data ?? [], null); - $this->setIfExists('settings', $data ?? [], null); $this->setIfExists('updatedAt', $data ?? [], null); $this->setIfExists('url', $data ?? [], null); } @@ -438,33 +431,6 @@ public function setId($id) return $this; } - /** - * Gets settings - * - * @return \Litebase\OpenAPI\Model\DatabaseSettings|null - */ - public function getSettings() - { - return $this->container['settings']; - } - - /** - * Sets settings - * - * @param \Litebase\OpenAPI\Model\DatabaseSettings|null $settings settings - * - * @return self - */ - public function setSettings($settings) - { - if (is_null($settings)) { - throw new \InvalidArgumentException('non-nullable settings cannot be null'); - } - $this->container['settings'] = $settings; - - return $this; - } - /** * Gets updatedAt * diff --git a/api/src/Model/DatabaseStoreResponse.php b/api/src/Model/DatabaseStoreResponse.php index a0ac40e..8be450c 100644 --- a/api/src/Model/DatabaseStoreResponse.php +++ b/api/src/Model/DatabaseStoreResponse.php @@ -27,7 +27,6 @@ class DatabaseStoreResponse implements ModelInterface, ArrayAccess, \JsonSeriali 'databaseId' => 'string', 'databaseName' => 'string', 'id' => 'int', - 'settings' => '\Litebase\OpenAPI\Model\DatabaseSettings', 'updatedAt' => '\DateTime', 'url' => 'string' ]; @@ -45,7 +44,6 @@ class DatabaseStoreResponse implements ModelInterface, ArrayAccess, \JsonSeriali 'databaseId' => null, 'databaseName' => null, 'id' => null, - 'settings' => null, 'updatedAt' => 'date-time', 'url' => null ]; @@ -61,7 +59,6 @@ class DatabaseStoreResponse implements ModelInterface, ArrayAccess, \JsonSeriali 'databaseId' => false, 'databaseName' => false, 'id' => false, - 'settings' => false, 'updatedAt' => false, 'url' => false ]; @@ -157,7 +154,6 @@ public function isNullableSetToNull(string $property): bool 'databaseId' => 'databaseId', 'databaseName' => 'databaseName', 'id' => 'id', - 'settings' => 'settings', 'updatedAt' => 'updatedAt', 'url' => 'url' ]; @@ -173,7 +169,6 @@ public function isNullableSetToNull(string $property): bool 'databaseId' => 'setDatabaseId', 'databaseName' => 'setDatabaseName', 'id' => 'setId', - 'settings' => 'setSettings', 'updatedAt' => 'setUpdatedAt', 'url' => 'setUrl' ]; @@ -189,7 +184,6 @@ public function isNullableSetToNull(string $property): bool 'databaseId' => 'getDatabaseId', 'databaseName' => 'getDatabaseName', 'id' => 'getId', - 'settings' => 'getSettings', 'updatedAt' => 'getUpdatedAt', 'url' => 'getUrl' ]; @@ -256,7 +250,6 @@ public function __construct(?array $data = null) $this->setIfExists('databaseId', $data ?? [], null); $this->setIfExists('databaseName', $data ?? [], null); $this->setIfExists('id', $data ?? [], null); - $this->setIfExists('settings', $data ?? [], null); $this->setIfExists('updatedAt', $data ?? [], null); $this->setIfExists('url', $data ?? [], null); } @@ -438,33 +431,6 @@ public function setId($id) return $this; } - /** - * Gets settings - * - * @return \Litebase\OpenAPI\Model\DatabaseSettings|null - */ - public function getSettings() - { - return $this->container['settings']; - } - - /** - * Sets settings - * - * @param \Litebase\OpenAPI\Model\DatabaseSettings|null $settings settings - * - * @return self - */ - public function setSettings($settings) - { - if (is_null($settings)) { - throw new \InvalidArgumentException('non-nullable settings cannot be null'); - } - $this->container['settings'] = $settings; - - return $this; - } - /** * Gets updatedAt * diff --git a/api/src/Model/GetDatabaseBranchSettings200Response.php b/api/src/Model/GetDatabaseBranchSettings200Response.php new file mode 100644 index 0000000..0dffb0f --- /dev/null +++ b/api/src/Model/GetDatabaseBranchSettings200Response.php @@ -0,0 +1,451 @@ + 'object', + 'message' => 'string', + 'status' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'data' => null, + 'message' => null, + 'status' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'data' => false, + 'message' => false, + 'status' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'data' => 'data', + 'message' => 'message', + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'data' => 'setData', + 'message' => 'setMessage', + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'data' => 'getData', + 'message' => 'getMessage', + 'status' => 'getStatus' + ]; + + /** + * 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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('data', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['data'] === null) { + $invalidProperties[] = "'data' can't be null"; + } + if ($this->container['message'] === null) { + $invalidProperties[] = "'message' can't be null"; + } + if ($this->container['status'] === null) { + $invalidProperties[] = "'status' can't be null"; + } + 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 count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets data + * + * @return object + */ + public function getData() + { + return $this->container['data']; + } + + /** + * Sets data + * + * @param object $data Return value from .DatabaseBranchSettingsShowResponse() + * + * @return self + */ + public function setData($data) + { + if (is_null($data)) { + throw new \InvalidArgumentException('non-nullable data cannot be null'); + } + $this->container['data'] = $data; + + return $this; + } + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string $message Response message + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets status + * + * @return string + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string $status Response status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + 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): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link 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. + */ + #[\ReturnTypeWillChange] + 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)); + } +} + + diff --git a/api/src/Model/UpdateDatabaseBranchSettings200Response.php b/api/src/Model/UpdateDatabaseBranchSettings200Response.php new file mode 100644 index 0000000..6625ed9 --- /dev/null +++ b/api/src/Model/UpdateDatabaseBranchSettings200Response.php @@ -0,0 +1,451 @@ + 'object', + 'message' => 'string', + 'status' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'data' => null, + 'message' => null, + 'status' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'data' => false, + 'message' => false, + 'status' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * 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 nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'data' => 'data', + 'message' => 'message', + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'data' => 'setData', + 'message' => 'setMessage', + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'data' => 'getData', + 'message' => 'getMessage', + 'status' => 'getStatus' + ]; + + /** + * 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[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('data', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['data'] === null) { + $invalidProperties[] = "'data' can't be null"; + } + if ($this->container['message'] === null) { + $invalidProperties[] = "'message' can't be null"; + } + if ($this->container['status'] === null) { + $invalidProperties[] = "'status' can't be null"; + } + 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 count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets data + * + * @return object + */ + public function getData() + { + return $this->container['data']; + } + + /** + * Sets data + * + * @param object $data Return value from .DatabaseBranchSettingsUpdateResponse() + * + * @return self + */ + public function setData($data) + { + if (is_null($data)) { + throw new \InvalidArgumentException('non-nullable data cannot be null'); + } + $this->container['data'] = $data; + + return $this; + } + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string $message Response message + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets status + * + * @return string + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string $status Response status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + 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): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link 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. + */ + #[\ReturnTypeWillChange] + 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)); + } +} + + diff --git a/src/ApiClient.php b/src/ApiClient.php index e2fdacc..04fe0cb 100644 --- a/src/ApiClient.php +++ b/src/ApiClient.php @@ -12,6 +12,7 @@ use Litebase\OpenAPI\API\DatabaseApi; use Litebase\OpenAPI\API\DatabaseBackupApi; use Litebase\OpenAPI\API\DatabaseBranchApi; +use Litebase\OpenAPI\API\DatabaseBranchSettingsApi; use Litebase\OpenAPI\API\DatabaseExportApi; use Litebase\OpenAPI\API\DatabaseExportEndApi; use Litebase\OpenAPI\API\DatabaseExportPartApi; @@ -107,6 +108,11 @@ public function databaseBranch(): DatabaseBranchApi return new DatabaseBranchApi($this->getHttpClient(), $this->config); } + public function databaseBranchSettings(): DatabaseBranchSettingsApi + { + return new DatabaseBranchSettingsApi($this->getHttpClient(), $this->config); + } + public function databaseExport(): DatabaseExportApi { return new DatabaseExportApi($this->getHttpClient(), $this->config); diff --git a/tests/Integration/ApiClientTestRunner.php b/tests/Integration/ApiClientTestRunner.php index ca5459b..808d02d 100644 --- a/tests/Integration/ApiClientTestRunner.php +++ b/tests/Integration/ApiClientTestRunner.php @@ -250,13 +250,13 @@ protected function captureResponseData(array $captured, ResponseData $responseSp $method = "get$pascalCasePart"; if (! is_object($currentObject) || ! method_exists($currentObject, $method)) { - throw new \Exception("Method {$method} does not exist on ".(is_object($currentObject) ? get_class($currentObject) : gettype($currentObject))); + throw new \Exception("Method {$method} does not exist on " . (is_object($currentObject) ? get_class($currentObject) : gettype($currentObject))); } $array = $currentObject->{$method}(); if (! is_array($array)) { - throw new \Exception("Expected array from {$method}(), got ".gettype($array)); + throw new \Exception("Expected array from {$method}(), got " . gettype($array)); } if (! isset($array[$index])) { @@ -284,13 +284,13 @@ protected function captureResponseData(array $captured, ResponseData $responseSp $snakeCaseKey = strtolower((string) preg_replace('/(?{$snakeCaseKey} ?? $currentObject->{$segment}; } } else { - throw new \Exception("Cannot access property '{$segment}' on ".gettype($currentObject)); + throw new \Exception("Cannot access property '{$segment}' on " . gettype($currentObject)); } } } @@ -423,7 +423,7 @@ protected function prepareRequestParameters(RequestData $request, $captured): ar if (array_key_exists($key, $captured)) { $params[] = $captured[$key]; } else { - throw new \Exception("Captured parameter '".$key."' not found for operation '{$request->operation}'"); + throw new \Exception("Captured parameter '" . $key . "' not found for operation '{$request->operation}'"); } } }