Phase F
This commit is contained in:
@@ -134,6 +134,85 @@ function hexagamecloud_TestConnection(array $params): array
|
||||
}
|
||||
}
|
||||
|
||||
function hexagamecloud_ListAccounts(array $params): array
|
||||
{
|
||||
try {
|
||||
$client = new HexaGameCloudApiClient($params);
|
||||
$response = $client->listAccounts();
|
||||
$accounts = [];
|
||||
|
||||
foreach ($response['accounts'] ?? [] as $account) {
|
||||
$accounts[] = [
|
||||
'uuid' => $account['externalServiceId'] ?? '',
|
||||
'domain' => $account['domain'] ?? '',
|
||||
'username' => $account['username'] ?? '',
|
||||
'status' => $account['status'] ?? 'Active',
|
||||
];
|
||||
}
|
||||
|
||||
return $accounts;
|
||||
} catch (Throwable $exception) {
|
||||
logModuleCall('hexagamecloud', __FUNCTION__, $params, $exception->getMessage());
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function hexagamecloud_MetricProvider(array $params)
|
||||
{
|
||||
try {
|
||||
$client = new HexaGameCloudApiClient($params);
|
||||
$serviceId = (string) $params['serviceid'];
|
||||
$usage = $client->getServiceUsage($serviceId, hexagamecloud_resolveUsageQuery($params));
|
||||
|
||||
return [
|
||||
'metrics' => $usage['metrics'] ?? [],
|
||||
];
|
||||
} catch (Throwable $exception) {
|
||||
logModuleCall('hexagamecloud', __FUNCTION__, $params, $exception->getMessage());
|
||||
return ['metrics' => []];
|
||||
}
|
||||
}
|
||||
|
||||
function hexagamecloud_UsageUpdate(array $params)
|
||||
{
|
||||
try {
|
||||
$client = new HexaGameCloudApiClient($params);
|
||||
$serviceId = (string) $params['serviceid'];
|
||||
$usage = $client->getServiceUsage($serviceId, hexagamecloud_resolveUsageQuery($params));
|
||||
$usageUpdate = $usage['usageUpdate'] ?? [];
|
||||
|
||||
return [
|
||||
'diskusage' => (float) ($usageUpdate['diskUsageGiB'] ?? 0),
|
||||
'bandwidth' => (float) ($usageUpdate['bandwidthGiB'] ?? 0),
|
||||
];
|
||||
} catch (Throwable $exception) {
|
||||
logModuleCall('hexagamecloud', __FUNCTION__, $params, $exception->getMessage());
|
||||
return [
|
||||
'diskusage' => 0,
|
||||
'bandwidth' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
function hexagamecloud_resolveUsageQuery(array $params): array
|
||||
{
|
||||
$query = [];
|
||||
|
||||
if (!empty($params['usageperiodstart'])) {
|
||||
$query['periodStart'] = gmdate('c', strtotime((string) $params['usageperiodstart']));
|
||||
}
|
||||
|
||||
if (!empty($params['usageperiodend'])) {
|
||||
$query['periodEnd'] = gmdate('c', strtotime((string) $params['usageperiodend']));
|
||||
}
|
||||
|
||||
if (!empty($params['testmode']) || !empty($params['configoption4'])) {
|
||||
$query['testMode'] = true;
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
function hexagamecloud_lifecycleAction(array $params, string $action, array $body = []): string
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user