Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[server] Add admin user logout #1307 #1311

Merged
merged 5 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agdb_api/php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Class | Method | HTTP request | Description
*AgdbApi* | [**adminUserAdd**](docs/Api/AgdbApi.md#adminuseradd) | **POST** /api/v1/admin/user/{username}/add |
*AgdbApi* | [**adminUserChangePassword**](docs/Api/AgdbApi.md#adminuserchangepassword) | **PUT** /api/v1/admin/user/{username}/change_password |
*AgdbApi* | [**adminUserList**](docs/Api/AgdbApi.md#adminuserlist) | **GET** /api/v1/admin/user/list |
*AgdbApi* | [**adminUserLogout**](docs/Api/AgdbApi.md#adminuserlogout) | **POST** /api/v1/admin/user/{username}/logout |
*AgdbApi* | [**adminUserRemove**](docs/Api/AgdbApi.md#adminuserremove) | **DELETE** /api/v1/admin/user/{username}/remove |
*AgdbApi* | [**clusterStatus**](docs/Api/AgdbApi.md#clusterstatus) | **GET** /api/v1/cluster/status |
*AgdbApi* | [**dbAdd**](docs/Api/AgdbApi.md#dbadd) | **POST** /api/v1/db/{owner}/{db}/add |
Expand Down
58 changes: 58 additions & 0 deletions agdb_api/php/docs/Api/AgdbApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ All URIs are relative to http://localhost:3000, except if the operation defines
| [**adminUserAdd()**](AgdbApi.md#adminUserAdd) | **POST** /api/v1/admin/user/{username}/add | |
| [**adminUserChangePassword()**](AgdbApi.md#adminUserChangePassword) | **PUT** /api/v1/admin/user/{username}/change_password | |
| [**adminUserList()**](AgdbApi.md#adminUserList) | **GET** /api/v1/admin/user/list | |
| [**adminUserLogout()**](AgdbApi.md#adminUserLogout) | **POST** /api/v1/admin/user/{username}/logout | |
| [**adminUserRemove()**](AgdbApi.md#adminUserRemove) | **DELETE** /api/v1/admin/user/{username}/remove | |
| [**clusterStatus()**](AgdbApi.md#clusterStatus) | **GET** /api/v1/cluster/status | |
| [**dbAdd()**](AgdbApi.md#dbAdd) | **POST** /api/v1/db/{owner}/{db}/add | |
Expand Down Expand Up @@ -1168,6 +1169,63 @@ This endpoint does not need any parameter.
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)

## `adminUserLogout()`

```php
adminUserLogout($username)
```



### Example

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


// Configure Bearer authorization: Token
$config = Agnesoft\AgdbApi\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');


$apiInstance = new Agnesoft\AgdbApi\Api\AgdbApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$username = 'username_example'; // string | user name

try {
$apiInstance->adminUserLogout($username);
} catch (Exception $e) {
echo 'Exception when calling AgdbApi->adminUserLogout: ', $e->getMessage(), PHP_EOL;
}
```

### Parameters

| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **username** | **string**| user name | |

### Return type

void (empty response body)

### Authorization

[Token](../../README.md#Token)

### HTTP request headers

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

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

## `adminUserRemove()`

```php
Expand Down
1 change: 1 addition & 0 deletions agdb_api/php/docs/Model/UserStatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**login** | **bool** | |
**name** | **string** | |

[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
228 changes: 228 additions & 0 deletions agdb_api/php/lib/Api/AgdbApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class AgdbApi
'adminUserList' => [
'application/json',
],
'adminUserLogout' => [
'application/json',
],
'adminUserRemove' => [
'application/json',
],
Expand Down Expand Up @@ -5421,6 +5424,231 @@ public function adminUserListRequest(string $contentType = self::contentTypes['a
);
}

/**
* Operation adminUserLogout
*
* @param string $username user name (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminUserLogout'] 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 adminUserLogout($username, string $contentType = self::contentTypes['adminUserLogout'][0])
{
$this->adminUserLogoutWithHttpInfo($username, $contentType);
}

/**
* Operation adminUserLogoutWithHttpInfo
*
* @param string $username user name (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminUserLogout'] 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 adminUserLogoutWithHttpInfo($username, string $contentType = self::contentTypes['adminUserLogout'][0])
{
$request = $this->adminUserLogoutRequest($username, $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();

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 [null, $statusCode, $response->getHeaders()];

} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}

/**
* Operation adminUserLogoutAsync
*
* @param string $username user name (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminUserLogout'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function adminUserLogoutAsync($username, string $contentType = self::contentTypes['adminUserLogout'][0])
{
return $this->adminUserLogoutAsyncWithHttpInfo($username, $contentType)
->then(
function ($response) {
return $response[0];
}
);
}

/**
* Operation adminUserLogoutAsyncWithHttpInfo
*
* @param string $username user name (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminUserLogout'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function adminUserLogoutAsyncWithHttpInfo($username, string $contentType = self::contentTypes['adminUserLogout'][0])
{
$returnType = '';
$request = $this->adminUserLogoutRequest($username, $contentType);

return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
return [null, $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 'adminUserLogout'
*
* @param string $username user name (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['adminUserLogout'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function adminUserLogoutRequest($username, string $contentType = self::contentTypes['adminUserLogout'][0])
{

// verify the required parameter 'username' is set
if ($username === null || (is_array($username) && count($username) === 0)) {
throw new \InvalidArgumentException(
'Missing the required parameter $username when calling adminUserLogout'
);
}


$resourcePath = '/api/v1/admin/user/{username}/logout';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;



// path params
if ($username !== null) {
$resourcePath = str_replace(
'{' . 'username' . '}',
ObjectSerializer::toPathValue($username),
$resourcePath
);
}


$headers = $this->headerSelector->selectHeaders(
[],
$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 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
);

$operationHost = $this->config->getHost();
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}

/**
* Operation adminUserRemove
*
Expand Down
Loading
Loading