From a464627264a0e74c8fdc5d3ff6b1198b672d69fd Mon Sep 17 00:00:00 2001 From: Michael Vlach Date: Tue, 31 Dec 2024 16:40:22 +0100 Subject: [PATCH] [server] Split owner and db in http query arguments #1413 (#1425) update api --- agdb_api/php/docs/Api/AgdbApi.md | 40 +-- .../php/docs/Model/ServerDatabaseRename.md | 3 +- agdb_api/php/lib/Api/AgdbApi.php | 236 ++++++++++++------ .../php/lib/Model/ServerDatabaseRename.php | 73 ++++-- agdb_api/rust/src/api.rs | 8 +- agdb_api/typescript/src/openapi.d.ts | 27 +- agdb_server/openapi.json | 48 +++- agdb_server/src/routes/admin/db.rs | 28 +-- agdb_server/src/routes/db.rs | 31 +-- agdb_server/src/utilities.rs | 7 +- 10 files changed, 326 insertions(+), 175 deletions(-) diff --git a/agdb_api/php/docs/Api/AgdbApi.md b/agdb_api/php/docs/Api/AgdbApi.md index 0cbe54a9c..aac3f9aec 100644 --- a/agdb_api/php/docs/Api/AgdbApi.md +++ b/agdb_api/php/docs/Api/AgdbApi.md @@ -362,7 +362,7 @@ void (empty response body) ## `adminDbCopy()` ```php -adminDbCopy($owner, $db, $new_name) +adminDbCopy($owner, $db, $new_owner, $new_db) ``` @@ -386,10 +386,11 @@ $apiInstance = new Agnesoft\AgdbApi\Api\AgdbApi( ); $owner = 'owner_example'; // string | db owner user name $db = 'db_example'; // string | db name -$new_name = 'new_name_example'; // string +$new_owner = 'new_owner_example'; // string +$new_db = 'new_db_example'; // string try { - $apiInstance->adminDbCopy($owner, $db, $new_name); + $apiInstance->adminDbCopy($owner, $db, $new_owner, $new_db); } catch (Exception $e) { echo 'Exception when calling AgdbApi->adminDbCopy: ', $e->getMessage(), PHP_EOL; } @@ -401,7 +402,8 @@ try { | ------------- | ------------- | ------------- | ------------- | | **owner** | **string**| db owner user name | | | **db** | **string**| db name | | -| **new_name** | **string**| | | +| **new_owner** | **string**| | | +| **new_db** | **string**| | | ### Return type @@ -780,7 +782,7 @@ void (empty response body) ## `adminDbRename()` ```php -adminDbRename($owner, $db, $new_name) +adminDbRename($owner, $db, $new_owner, $new_db) ``` @@ -804,10 +806,11 @@ $apiInstance = new Agnesoft\AgdbApi\Api\AgdbApi( ); $owner = 'owner_example'; // string | db owner user name $db = 'db_example'; // string | db name -$new_name = 'new_name_example'; // string +$new_owner = 'new_owner_example'; // string +$new_db = 'new_db_example'; // string try { - $apiInstance->adminDbRename($owner, $db, $new_name); + $apiInstance->adminDbRename($owner, $db, $new_owner, $new_db); } catch (Exception $e) { echo 'Exception when calling AgdbApi->adminDbRename: ', $e->getMessage(), PHP_EOL; } @@ -819,7 +822,8 @@ try { | ------------- | ------------- | ------------- | ------------- | | **owner** | **string**| db owner user name | | | **db** | **string**| db name | | -| **new_name** | **string**| | | +| **new_owner** | **string**| | | +| **new_db** | **string**| | | ### Return type @@ -2000,7 +2004,7 @@ void (empty response body) ## `dbCopy()` ```php -dbCopy($owner, $db, $new_name) +dbCopy($owner, $db, $new_owner, $new_db) ``` @@ -2024,10 +2028,11 @@ $apiInstance = new Agnesoft\AgdbApi\Api\AgdbApi( ); $owner = 'owner_example'; // string | db owner user name $db = 'db_example'; // string | db name -$new_name = 'new_name_example'; // string +$new_owner = 'new_owner_example'; // string +$new_db = 'new_db_example'; // string try { - $apiInstance->dbCopy($owner, $db, $new_name); + $apiInstance->dbCopy($owner, $db, $new_owner, $new_db); } catch (Exception $e) { echo 'Exception when calling AgdbApi->dbCopy: ', $e->getMessage(), PHP_EOL; } @@ -2039,7 +2044,8 @@ try { | ------------- | ------------- | ------------- | ------------- | | **owner** | **string**| db owner user name | | | **db** | **string**| db name | | -| **new_name** | **string**| | | +| **new_owner** | **string**| | | +| **new_db** | **string**| | | ### Return type @@ -2418,7 +2424,7 @@ void (empty response body) ## `dbRename()` ```php -dbRename($owner, $db, $new_name) +dbRename($owner, $db, $new_owner, $new_db) ``` @@ -2442,10 +2448,11 @@ $apiInstance = new Agnesoft\AgdbApi\Api\AgdbApi( ); $owner = 'owner_example'; // string | db owner user name $db = 'db_example'; // string | db name -$new_name = 'new_name_example'; // string +$new_owner = 'new_owner_example'; // string +$new_db = 'new_db_example'; // string try { - $apiInstance->dbRename($owner, $db, $new_name); + $apiInstance->dbRename($owner, $db, $new_owner, $new_db); } catch (Exception $e) { echo 'Exception when calling AgdbApi->dbRename: ', $e->getMessage(), PHP_EOL; } @@ -2457,7 +2464,8 @@ try { | ------------- | ------------- | ------------- | ------------- | | **owner** | **string**| db owner user name | | | **db** | **string**| db name | | -| **new_name** | **string**| | | +| **new_owner** | **string**| | | +| **new_db** | **string**| | | ### Return type diff --git a/agdb_api/php/docs/Model/ServerDatabaseRename.md b/agdb_api/php/docs/Model/ServerDatabaseRename.md index fd9ce4e60..e2f72203b 100644 --- a/agdb_api/php/docs/Model/ServerDatabaseRename.md +++ b/agdb_api/php/docs/Model/ServerDatabaseRename.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**new_name** | **string** | | +**new_db** | **string** | | +**new_owner** | **string** | | [[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/agdb_api/php/lib/Api/AgdbApi.php b/agdb_api/php/lib/Api/AgdbApi.php index 965748ed2..29ac7e079 100644 --- a/agdb_api/php/lib/Api/AgdbApi.php +++ b/agdb_api/php/lib/Api/AgdbApi.php @@ -1684,16 +1684,17 @@ public function adminDbConvertRequest($owner, $db, $db_type, string $contentType * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name new_name (required) + * @param string $new_owner new_owner (required) + * @param string $new_db new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminDbCopy'] to see the possible values for this operation * * @throws \Agnesoft\AgdbApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return void */ - public function adminDbCopy($owner, $db, $new_name, string $contentType = self::contentTypes['adminDbCopy'][0]) + public function adminDbCopy($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['adminDbCopy'][0]) { - $this->adminDbCopyWithHttpInfo($owner, $db, $new_name, $contentType); + $this->adminDbCopyWithHttpInfo($owner, $db, $new_owner, $new_db, $contentType); } /** @@ -1701,16 +1702,17 @@ public function adminDbCopy($owner, $db, $new_name, string $contentType = self:: * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminDbCopy'] to see the possible values for this operation * * @throws \Agnesoft\AgdbApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function adminDbCopyWithHttpInfo($owner, $db, $new_name, string $contentType = self::contentTypes['adminDbCopy'][0]) + public function adminDbCopyWithHttpInfo($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['adminDbCopy'][0]) { - $request = $this->adminDbCopyRequest($owner, $db, $new_name, $contentType); + $request = $this->adminDbCopyRequest($owner, $db, $new_owner, $new_db, $contentType); try { $options = $this->createHttpClientOption(); @@ -1749,15 +1751,16 @@ public function adminDbCopyWithHttpInfo($owner, $db, $new_name, string $contentT * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminDbCopy'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function adminDbCopyAsync($owner, $db, $new_name, string $contentType = self::contentTypes['adminDbCopy'][0]) + public function adminDbCopyAsync($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['adminDbCopy'][0]) { - return $this->adminDbCopyAsyncWithHttpInfo($owner, $db, $new_name, $contentType) + return $this->adminDbCopyAsyncWithHttpInfo($owner, $db, $new_owner, $new_db, $contentType) ->then( function ($response) { return $response[0]; @@ -1770,16 +1773,17 @@ function ($response) { * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminDbCopy'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function adminDbCopyAsyncWithHttpInfo($owner, $db, $new_name, string $contentType = self::contentTypes['adminDbCopy'][0]) + public function adminDbCopyAsyncWithHttpInfo($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['adminDbCopy'][0]) { $returnType = ''; - $request = $this->adminDbCopyRequest($owner, $db, $new_name, $contentType); + $request = $this->adminDbCopyRequest($owner, $db, $new_owner, $new_db, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1809,13 +1813,14 @@ function ($exception) { * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminDbCopy'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function adminDbCopyRequest($owner, $db, $new_name, string $contentType = self::contentTypes['adminDbCopy'][0]) + public function adminDbCopyRequest($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['adminDbCopy'][0]) { // verify the required parameter 'owner' is set @@ -1832,10 +1837,17 @@ public function adminDbCopyRequest($owner, $db, $new_name, string $contentType = ); } - // verify the required parameter 'new_name' is set - if ($new_name === null || (is_array($new_name) && count($new_name) === 0)) { + // verify the required parameter 'new_owner' is set + if ($new_owner === null || (is_array($new_owner) && count($new_owner) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $new_name when calling adminDbCopy' + 'Missing the required parameter $new_owner when calling adminDbCopy' + ); + } + + // verify the required parameter 'new_db' is set + if ($new_db === null || (is_array($new_db) && count($new_db) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $new_db when calling adminDbCopy' ); } @@ -1849,8 +1861,17 @@ public function adminDbCopyRequest($owner, $db, $new_name, string $contentType = // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $new_name, - 'new_name', // param base name + $new_owner, + 'new_owner', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $new_db, + 'new_db', // param base name 'string', // openApiType 'form', // style true, // explode @@ -3698,16 +3719,17 @@ public function adminDbRemoveRequest($owner, $db, string $contentType = self::co * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name new_name (required) + * @param string $new_owner new_owner (required) + * @param string $new_db new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminDbRename'] to see the possible values for this operation * * @throws \Agnesoft\AgdbApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return void */ - public function adminDbRename($owner, $db, $new_name, string $contentType = self::contentTypes['adminDbRename'][0]) + public function adminDbRename($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['adminDbRename'][0]) { - $this->adminDbRenameWithHttpInfo($owner, $db, $new_name, $contentType); + $this->adminDbRenameWithHttpInfo($owner, $db, $new_owner, $new_db, $contentType); } /** @@ -3715,16 +3737,17 @@ public function adminDbRename($owner, $db, $new_name, string $contentType = self * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminDbRename'] to see the possible values for this operation * * @throws \Agnesoft\AgdbApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function adminDbRenameWithHttpInfo($owner, $db, $new_name, string $contentType = self::contentTypes['adminDbRename'][0]) + public function adminDbRenameWithHttpInfo($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['adminDbRename'][0]) { - $request = $this->adminDbRenameRequest($owner, $db, $new_name, $contentType); + $request = $this->adminDbRenameRequest($owner, $db, $new_owner, $new_db, $contentType); try { $options = $this->createHttpClientOption(); @@ -3763,15 +3786,16 @@ public function adminDbRenameWithHttpInfo($owner, $db, $new_name, string $conten * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminDbRename'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function adminDbRenameAsync($owner, $db, $new_name, string $contentType = self::contentTypes['adminDbRename'][0]) + public function adminDbRenameAsync($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['adminDbRename'][0]) { - return $this->adminDbRenameAsyncWithHttpInfo($owner, $db, $new_name, $contentType) + return $this->adminDbRenameAsyncWithHttpInfo($owner, $db, $new_owner, $new_db, $contentType) ->then( function ($response) { return $response[0]; @@ -3784,16 +3808,17 @@ function ($response) { * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminDbRename'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function adminDbRenameAsyncWithHttpInfo($owner, $db, $new_name, string $contentType = self::contentTypes['adminDbRename'][0]) + public function adminDbRenameAsyncWithHttpInfo($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['adminDbRename'][0]) { $returnType = ''; - $request = $this->adminDbRenameRequest($owner, $db, $new_name, $contentType); + $request = $this->adminDbRenameRequest($owner, $db, $new_owner, $new_db, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -3823,13 +3848,14 @@ function ($exception) { * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminDbRename'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function adminDbRenameRequest($owner, $db, $new_name, string $contentType = self::contentTypes['adminDbRename'][0]) + public function adminDbRenameRequest($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['adminDbRename'][0]) { // verify the required parameter 'owner' is set @@ -3846,10 +3872,17 @@ public function adminDbRenameRequest($owner, $db, $new_name, string $contentType ); } - // verify the required parameter 'new_name' is set - if ($new_name === null || (is_array($new_name) && count($new_name) === 0)) { + // verify the required parameter 'new_owner' is set + if ($new_owner === null || (is_array($new_owner) && count($new_owner) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $new_name when calling adminDbRename' + 'Missing the required parameter $new_owner when calling adminDbRename' + ); + } + + // verify the required parameter 'new_db' is set + if ($new_db === null || (is_array($new_db) && count($new_db) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $new_db when calling adminDbRename' ); } @@ -3863,8 +3896,17 @@ public function adminDbRenameRequest($owner, $db, $new_name, string $contentType // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $new_name, - 'new_name', // param base name + $new_owner, + 'new_owner', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $new_db, + 'new_db', // param base name 'string', // openApiType 'form', // style true, // explode @@ -9173,16 +9215,17 @@ public function dbConvertRequest($owner, $db, $db_type, string $contentType = se * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name new_name (required) + * @param string $new_owner new_owner (required) + * @param string $new_db new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dbCopy'] to see the possible values for this operation * * @throws \Agnesoft\AgdbApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return void */ - public function dbCopy($owner, $db, $new_name, string $contentType = self::contentTypes['dbCopy'][0]) + public function dbCopy($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['dbCopy'][0]) { - $this->dbCopyWithHttpInfo($owner, $db, $new_name, $contentType); + $this->dbCopyWithHttpInfo($owner, $db, $new_owner, $new_db, $contentType); } /** @@ -9190,16 +9233,17 @@ public function dbCopy($owner, $db, $new_name, string $contentType = self::conte * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dbCopy'] to see the possible values for this operation * * @throws \Agnesoft\AgdbApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function dbCopyWithHttpInfo($owner, $db, $new_name, string $contentType = self::contentTypes['dbCopy'][0]) + public function dbCopyWithHttpInfo($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['dbCopy'][0]) { - $request = $this->dbCopyRequest($owner, $db, $new_name, $contentType); + $request = $this->dbCopyRequest($owner, $db, $new_owner, $new_db, $contentType); try { $options = $this->createHttpClientOption(); @@ -9238,15 +9282,16 @@ public function dbCopyWithHttpInfo($owner, $db, $new_name, string $contentType = * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dbCopy'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function dbCopyAsync($owner, $db, $new_name, string $contentType = self::contentTypes['dbCopy'][0]) + public function dbCopyAsync($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['dbCopy'][0]) { - return $this->dbCopyAsyncWithHttpInfo($owner, $db, $new_name, $contentType) + return $this->dbCopyAsyncWithHttpInfo($owner, $db, $new_owner, $new_db, $contentType) ->then( function ($response) { return $response[0]; @@ -9259,16 +9304,17 @@ function ($response) { * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dbCopy'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function dbCopyAsyncWithHttpInfo($owner, $db, $new_name, string $contentType = self::contentTypes['dbCopy'][0]) + public function dbCopyAsyncWithHttpInfo($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['dbCopy'][0]) { $returnType = ''; - $request = $this->dbCopyRequest($owner, $db, $new_name, $contentType); + $request = $this->dbCopyRequest($owner, $db, $new_owner, $new_db, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -9298,13 +9344,14 @@ function ($exception) { * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dbCopy'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function dbCopyRequest($owner, $db, $new_name, string $contentType = self::contentTypes['dbCopy'][0]) + public function dbCopyRequest($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['dbCopy'][0]) { // verify the required parameter 'owner' is set @@ -9321,10 +9368,17 @@ public function dbCopyRequest($owner, $db, $new_name, string $contentType = self ); } - // verify the required parameter 'new_name' is set - if ($new_name === null || (is_array($new_name) && count($new_name) === 0)) { + // verify the required parameter 'new_owner' is set + if ($new_owner === null || (is_array($new_owner) && count($new_owner) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $new_name when calling dbCopy' + 'Missing the required parameter $new_owner when calling dbCopy' + ); + } + + // verify the required parameter 'new_db' is set + if ($new_db === null || (is_array($new_db) && count($new_db) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $new_db when calling dbCopy' ); } @@ -9338,8 +9392,17 @@ public function dbCopyRequest($owner, $db, $new_name, string $contentType = self // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $new_name, - 'new_name', // param base name + $new_owner, + 'new_owner', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $new_db, + 'new_db', // param base name 'string', // openApiType 'form', // style true, // explode @@ -11187,16 +11250,17 @@ public function dbRemoveRequest($owner, $db, string $contentType = self::content * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name new_name (required) + * @param string $new_owner new_owner (required) + * @param string $new_db new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dbRename'] to see the possible values for this operation * * @throws \Agnesoft\AgdbApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return void */ - public function dbRename($owner, $db, $new_name, string $contentType = self::contentTypes['dbRename'][0]) + public function dbRename($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['dbRename'][0]) { - $this->dbRenameWithHttpInfo($owner, $db, $new_name, $contentType); + $this->dbRenameWithHttpInfo($owner, $db, $new_owner, $new_db, $contentType); } /** @@ -11204,16 +11268,17 @@ public function dbRename($owner, $db, $new_name, string $contentType = self::con * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dbRename'] to see the possible values for this operation * * @throws \Agnesoft\AgdbApi\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function dbRenameWithHttpInfo($owner, $db, $new_name, string $contentType = self::contentTypes['dbRename'][0]) + public function dbRenameWithHttpInfo($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['dbRename'][0]) { - $request = $this->dbRenameRequest($owner, $db, $new_name, $contentType); + $request = $this->dbRenameRequest($owner, $db, $new_owner, $new_db, $contentType); try { $options = $this->createHttpClientOption(); @@ -11252,15 +11317,16 @@ public function dbRenameWithHttpInfo($owner, $db, $new_name, string $contentType * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dbRename'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function dbRenameAsync($owner, $db, $new_name, string $contentType = self::contentTypes['dbRename'][0]) + public function dbRenameAsync($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['dbRename'][0]) { - return $this->dbRenameAsyncWithHttpInfo($owner, $db, $new_name, $contentType) + return $this->dbRenameAsyncWithHttpInfo($owner, $db, $new_owner, $new_db, $contentType) ->then( function ($response) { return $response[0]; @@ -11273,16 +11339,17 @@ function ($response) { * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dbRename'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function dbRenameAsyncWithHttpInfo($owner, $db, $new_name, string $contentType = self::contentTypes['dbRename'][0]) + public function dbRenameAsyncWithHttpInfo($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['dbRename'][0]) { $returnType = ''; - $request = $this->dbRenameRequest($owner, $db, $new_name, $contentType); + $request = $this->dbRenameRequest($owner, $db, $new_owner, $new_db, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -11312,13 +11379,14 @@ function ($exception) { * * @param string $owner db owner user name (required) * @param string $db db name (required) - * @param string $new_name (required) + * @param string $new_owner (required) + * @param string $new_db (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['dbRename'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function dbRenameRequest($owner, $db, $new_name, string $contentType = self::contentTypes['dbRename'][0]) + public function dbRenameRequest($owner, $db, $new_owner, $new_db, string $contentType = self::contentTypes['dbRename'][0]) { // verify the required parameter 'owner' is set @@ -11335,10 +11403,17 @@ public function dbRenameRequest($owner, $db, $new_name, string $contentType = se ); } - // verify the required parameter 'new_name' is set - if ($new_name === null || (is_array($new_name) && count($new_name) === 0)) { + // verify the required parameter 'new_owner' is set + if ($new_owner === null || (is_array($new_owner) && count($new_owner) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $new_name when calling dbRename' + 'Missing the required parameter $new_owner when calling dbRename' + ); + } + + // verify the required parameter 'new_db' is set + if ($new_db === null || (is_array($new_db) && count($new_db) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $new_db when calling dbRename' ); } @@ -11352,8 +11427,17 @@ public function dbRenameRequest($owner, $db, $new_name, string $contentType = se // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $new_name, - 'new_name', // param base name + $new_owner, + 'new_owner', // param base name + 'string', // openApiType + 'form', // style + true, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $new_db, + 'new_db', // param base name 'string', // openApiType 'form', // style true, // explode diff --git a/agdb_api/php/lib/Model/ServerDatabaseRename.php b/agdb_api/php/lib/Model/ServerDatabaseRename.php index 33340354b..e8d56290c 100644 --- a/agdb_api/php/lib/Model/ServerDatabaseRename.php +++ b/agdb_api/php/lib/Model/ServerDatabaseRename.php @@ -57,7 +57,8 @@ class ServerDatabaseRename implements ModelInterface, ArrayAccess, \JsonSerializ * @var string[] */ protected static $openAPITypes = [ - 'new_name' => 'string' + 'new_db' => 'string', + 'new_owner' => 'string' ]; /** @@ -68,7 +69,8 @@ class ServerDatabaseRename implements ModelInterface, ArrayAccess, \JsonSerializ * @psalm-var array */ protected static $openAPIFormats = [ - 'new_name' => null + 'new_db' => null, + 'new_owner' => null ]; /** @@ -77,7 +79,8 @@ class ServerDatabaseRename implements ModelInterface, ArrayAccess, \JsonSerializ * @var boolean[] */ protected static array $openAPINullables = [ - 'new_name' => false + 'new_db' => false, + 'new_owner' => false ]; /** @@ -166,7 +169,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $attributeMap = [ - 'new_name' => 'new_name' + 'new_db' => 'new_db', + 'new_owner' => 'new_owner' ]; /** @@ -175,7 +179,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $setters = [ - 'new_name' => 'setNewName' + 'new_db' => 'setNewDb', + 'new_owner' => 'setNewOwner' ]; /** @@ -184,7 +189,8 @@ public function isNullableSetToNull(string $property): bool * @var string[] */ protected static $getters = [ - 'new_name' => 'getNewName' + 'new_db' => 'getNewDb', + 'new_owner' => 'getNewOwner' ]; /** @@ -244,7 +250,8 @@ public function getModelName() */ public function __construct(array $data = null) { - $this->setIfExists('new_name', $data ?? [], null); + $this->setIfExists('new_db', $data ?? [], null); + $this->setIfExists('new_owner', $data ?? [], null); } /** @@ -274,8 +281,11 @@ public function listInvalidProperties() { $invalidProperties = []; - if ($this->container['new_name'] === null) { - $invalidProperties[] = "'new_name' can't be null"; + if ($this->container['new_db'] === null) { + $invalidProperties[] = "'new_db' can't be null"; + } + if ($this->container['new_owner'] === null) { + $invalidProperties[] = "'new_owner' can't be null"; } return $invalidProperties; } @@ -293,28 +303,55 @@ public function valid() /** - * Gets new_name + * Gets new_db + * + * @return string + */ + public function getNewDb() + { + return $this->container['new_db']; + } + + /** + * Sets new_db + * + * @param string $new_db new_db + * + * @return self + */ + public function setNewDb($new_db) + { + if (is_null($new_db)) { + throw new \InvalidArgumentException('non-nullable new_db cannot be null'); + } + $this->container['new_db'] = $new_db; + + return $this; + } + + /** + * Gets new_owner * * @return string */ - public function getNewName() + public function getNewOwner() { - return $this->container['new_name']; + return $this->container['new_owner']; } /** - * Sets new_name + * Sets new_owner * - * @param string $new_name new_name + * @param string $new_owner new_owner * * @return self */ - public function setNewName($new_name) + public function setNewOwner($new_owner) { - if (is_null($new_name)) { - throw new \InvalidArgumentException('non-nullable new_name cannot be null'); + if (is_null($new_owner)) { + throw new \InvalidArgumentException('non-nullable new_owner cannot be null'); } - $this->container['new_name'] = $new_name; + $this->container['new_owner'] = $new_owner; return $this; } diff --git a/agdb_api/rust/src/api.rs b/agdb_api/rust/src/api.rs index 8c1a56fc5..4cf4fd0d0 100644 --- a/agdb_api/rust/src/api.rs +++ b/agdb_api/rust/src/api.rs @@ -122,7 +122,7 @@ impl AgdbApi { .client .post::<(), ()>( &self.url(&format!( - "/admin/db/{owner}/{db}/copy?new_name={new_owner}/{new_db}" + "/admin/db/{owner}/{db}/copy?new_owner={new_owner}&new_db={new_db}" )), &None, &self.token, @@ -210,7 +210,7 @@ impl AgdbApi { .client .post::<(), ()>( &self.url(&format!( - "/admin/db/{owner}/{db}/rename?new_name={new_owner}/{new_db}" + "/admin/db/{owner}/{db}/rename?new_owner={new_owner}&new_db={new_db}" )), &None, &self.token, @@ -457,7 +457,7 @@ impl AgdbApi { .client .post::<(), ()>( &self.url(&format!( - "/db/{owner}/{db}/copy?new_name={new_owner}/{new_db}" + "/db/{owner}/{db}/copy?new_owner={new_owner}&new_db={new_db}" )), &None, &self.token, @@ -533,7 +533,7 @@ impl AgdbApi { .client .post::<(), ()>( &self.url(&format!( - "/db/{owner}/{db}/rename?new_name={new_owner}/{new_db}" + "/db/{owner}/{db}/rename?new_owner={new_owner}&new_db={new_db}" )), &None, &self.token, diff --git a/agdb_api/typescript/src/openapi.d.ts b/agdb_api/typescript/src/openapi.d.ts index 5ae7eb7c6..d3aa88313 100644 --- a/agdb_api/typescript/src/openapi.d.ts +++ b/agdb_api/typescript/src/openapi.d.ts @@ -1176,7 +1176,8 @@ declare namespace Components { size: number; // int64 } export interface ServerDatabaseRename { - new_name: string; + new_db: string; + new_owner: string; } export interface ServerDatabaseResource { resource: DbResource; @@ -1303,7 +1304,8 @@ declare namespace Paths { namespace AdminDbCopy { namespace Parameters { export type Db = string; - export type NewName = string; + export type NewDb = string; + export type NewOwner = string; export type Owner = string; } export interface PathParameters { @@ -1311,7 +1313,8 @@ declare namespace Paths { db: Parameters.Db; } export interface QueryParameters { - new_name: Parameters.NewName; + new_owner: Parameters.NewOwner; + new_db: Parameters.NewDb; } namespace Responses { export interface $201 { @@ -1425,7 +1428,8 @@ declare namespace Paths { namespace AdminDbRename { namespace Parameters { export type Db = string; - export type NewName = string; + export type NewDb = string; + export type NewOwner = string; export type Owner = string; } export interface PathParameters { @@ -1433,7 +1437,8 @@ declare namespace Paths { db: Parameters.Db; } export interface QueryParameters { - new_name: Parameters.NewName; + new_owner: Parameters.NewOwner; + new_db: Parameters.NewDb; } namespace Responses { export interface $201 { @@ -1776,7 +1781,8 @@ declare namespace Paths { namespace DbCopy { namespace Parameters { export type Db = string; - export type NewName = string; + export type NewDb = string; + export type NewOwner = string; export type Owner = string; } export interface PathParameters { @@ -1784,7 +1790,8 @@ declare namespace Paths { db: Parameters.Db; } export interface QueryParameters { - new_name: Parameters.NewName; + new_owner: Parameters.NewOwner; + new_db: Parameters.NewDb; } namespace Responses { export interface $201 { @@ -1910,7 +1917,8 @@ declare namespace Paths { namespace DbRename { namespace Parameters { export type Db = string; - export type NewName = string; + export type NewDb = string; + export type NewOwner = string; export type Owner = string; } export interface PathParameters { @@ -1918,7 +1926,8 @@ declare namespace Paths { db: Parameters.Db; } export interface QueryParameters { - new_name: Parameters.NewName; + new_owner: Parameters.NewOwner; + new_db: Parameters.NewDb; } namespace Responses { export interface $201 { diff --git a/agdb_server/openapi.json b/agdb_server/openapi.json index 33a681b17..f3b42228e 100644 --- a/agdb_server/openapi.json +++ b/agdb_server/openapi.json @@ -336,7 +336,15 @@ } }, { - "name": "new_name", + "name": "new_owner", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "new_db", "in": "query", "required": true, "schema": { @@ -655,7 +663,15 @@ } }, { - "name": "new_name", + "name": "new_owner", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "new_db", "in": "query", "required": true, "schema": { @@ -1609,7 +1625,15 @@ } }, { - "name": "new_name", + "name": "new_owner", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "new_db", "in": "query", "required": true, "schema": { @@ -1946,7 +1970,15 @@ } }, { - "name": "new_name", + "name": "new_owner", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "new_db", "in": "query", "required": true, "schema": { @@ -3664,10 +3696,14 @@ "ServerDatabaseRename": { "type": "object", "required": [ - "new_name" + "new_owner", + "new_db" ], "properties": { - "new_name": { + "new_db": { + "type": "string" + }, + "new_owner": { "type": "string" } } diff --git a/agdb_server/src/routes/admin/db.rs b/agdb_server/src/routes/admin/db.rs index cbe6640bf..7ef8b5570 100644 --- a/agdb_server/src/routes/admin/db.rs +++ b/agdb_server/src/routes/admin/db.rs @@ -23,7 +23,6 @@ use crate::server_db::ServerDb; use crate::server_error::permission_denied; use crate::server_error::ServerResponse; use crate::user_id::AdminId; -use crate::utilities::db_name; use crate::utilities::required_role; use agdb_api::DbAudit; use agdb_api::DbUserRole; @@ -267,16 +266,12 @@ pub(crate) async fn copy( Path((owner, db)): Path<(String, String)>, request: Query, ) -> ServerResponse { - let (new_owner, new_db) = request - .new_name - .split_once('/') - .ok_or(ErrorCode::DbInvalid)?; let owner_id = server_db.user_id(&owner).await?; let db_type = server_db.user_db(owner_id, &owner, &db).await?.db_type; - let new_owner_id = server_db.user_id(new_owner).await?; + let new_owner_id = server_db.user_id(&request.new_owner).await?; if server_db - .find_user_db_id(new_owner_id, new_owner, new_db) + .find_user_db_id(new_owner_id, &request.new_owner, &request.new_db) .await? .is_some() { @@ -287,8 +282,8 @@ pub(crate) async fn copy( .exec(DbCopy { owner, db, - new_owner: new_owner.to_string(), - new_db: new_db.to_string(), + new_owner: request.new_owner.clone(), + new_db: request.new_db.clone(), db_type, }) .await?; @@ -558,18 +553,13 @@ pub(crate) async fn rename( let owner_id = server_db.user_id(&owner).await?; let _ = server_db.user_db_id(owner_id, &owner, &db).await?; - if db_name(&owner, &db) == request.new_name { + if owner == request.new_owner && db == request.new_db { return Ok((StatusCode::CREATED, [("commit-index", String::new())])); } - let (new_owner, new_db) = request - .new_name - .split_once('/') - .ok_or(ErrorCode::DbInvalid)?; - - let new_owner_id = server_db.user_id(new_owner).await?; + let new_owner_id = server_db.user_id(&request.new_owner).await?; if server_db - .find_user_db_id(new_owner_id, new_owner, new_db) + .find_user_db_id(new_owner_id, &request.new_owner, &request.new_db) .await? .is_some() { @@ -580,8 +570,8 @@ pub(crate) async fn rename( .exec(DbRename { owner, db, - new_owner: new_owner.to_string(), - new_db: new_db.to_string(), + new_owner: request.new_owner.clone(), + new_db: request.new_db.clone(), }) .await?; diff --git a/agdb_server/src/routes/db.rs b/agdb_server/src/routes/db.rs index ff37a619d..fcc923441 100644 --- a/agdb_server/src/routes/db.rs +++ b/agdb_server/src/routes/db.rs @@ -20,7 +20,6 @@ use crate::server_error::permission_denied; use crate::server_error::ServerError; use crate::server_error::ServerResponse; use crate::user_id::UserId; -use crate::utilities::db_name; use crate::utilities::required_role; use agdb_api::DbAudit; use agdb_api::DbResource; @@ -42,7 +41,8 @@ use utoipa::ToSchema; #[derive(Deserialize, IntoParams, ToSchema)] #[into_params(parameter_in = Query)] pub struct ServerDatabaseRename { - pub new_name: String, + pub new_owner: String, + pub new_db: String, } #[derive(Deserialize, IntoParams, ToSchema)] @@ -310,19 +310,15 @@ pub(crate) async fn copy( Path((owner, db)): Path<(String, String)>, request: Query, ) -> ServerResponse { - let (new_owner, new_db) = request - .new_name - .split_once('/') - .ok_or(ErrorCode::DbInvalid)?; let db_type = server_db.user_db(user.0, &owner, &db).await?.db_type; let username = server_db.user_name(user.0).await?; - if new_owner != username { + if request.new_owner != username { return Err(permission_denied("cannot copy db to another user")); } if server_db - .find_user_db_id(user.0, new_owner, new_db) + .find_user_db_id(user.0, &request.new_owner, &request.new_db) .await? .is_some() { @@ -333,8 +329,8 @@ pub(crate) async fn copy( .exec(DbCopy { owner, db, - new_owner: new_owner.to_string(), - new_db: new_db.to_string(), + new_owner: request.new_owner.clone(), + new_db: request.new_db.clone(), db_type, }) .await?; @@ -641,22 +637,17 @@ pub(crate) async fn rename( ) -> ServerResponse { let _ = server_db.user_db_id(user.0, &owner, &db).await?; - if db_name(&owner, &db) == request.new_name { + if request.new_owner == owner && request.new_db == db { return Ok((StatusCode::CREATED, [("commit-index", String::new())])); } - let (new_owner, new_db) = request - .new_name - .split_once('/') - .ok_or(ErrorCode::DbInvalid)?; - if owner != server_db.user_name(user.0).await? { return Err(permission_denied("owner only")); } - let new_owner_id = server_db.user_id(new_owner).await?; + let new_owner_id = server_db.user_id(&request.new_owner).await?; if server_db - .find_user_db_id(new_owner_id, new_owner, new_db) + .find_user_db_id(new_owner_id, &request.new_owner, &request.new_db) .await? .is_some() { @@ -667,8 +658,8 @@ pub(crate) async fn rename( .exec(DbRename { owner, db, - new_owner: new_owner.to_string(), - new_db: new_db.to_string(), + new_owner: request.new_owner.to_string(), + new_db: request.new_db.to_string(), }) .await?; diff --git a/agdb_server/src/utilities.rs b/agdb_server/src/utilities.rs index b09d09b86..dee6f38bb 100644 --- a/agdb_server/src/utilities.rs +++ b/agdb_server/src/utilities.rs @@ -1,14 +1,9 @@ +use crate::server_error::ServerResult; use agdb::QueryType; use agdb_api::DbUserRole; use agdb_api::Queries; - -use crate::server_error::ServerResult; use std::path::Path; -pub(crate) fn db_name(owner: &str, db: &str) -> String { - format!("{owner}/{db}") -} - pub(crate) async fn get_size

(path: P) -> ServerResult where P: AsRef,