-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added helper functions for assigning and unassigning agents from tasks (
#1044) * added helper functions for assigning and unassigning agents from tasks * pass delete=True for test object creation * call tearDown for other test class manually to clean up
- Loading branch information
Showing
5 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use DBA\Agent; | ||
use DBA\Task; | ||
|
||
require_once(dirname(__FILE__) . "/../common/AbstractHelperAPI.class.php"); | ||
|
||
class AssignAgentHelperAPI extends AbstractHelperAPI { | ||
public static function getBaseUri(): string { | ||
return "/api/v2/helper/assignAgent"; | ||
} | ||
|
||
public static function getAvailableMethods(): array { | ||
return ['POST']; | ||
} | ||
|
||
public function getRequiredPermissions(string $method): array { | ||
return [Agent::PERM_UPDATE, Task::PERM_UPDATE]; | ||
} | ||
|
||
public function getFormFields(): array { | ||
return [ | ||
Agent::AGENT_ID => ["type" => "int"], | ||
Task::TASK_ID => ["type" => "int"], | ||
]; | ||
} | ||
|
||
public function actionPost($data): array|null { | ||
AgentUtils::assign($data[Agent::AGENT_ID], $data[Task::TASK_ID], $this->getCurrentUser()); | ||
|
||
# TODO: Check how to handle custom return messages that are not object, probably we want that to be in some kind of standardized form. | ||
return ["assign" => "success"]; | ||
} | ||
} | ||
|
||
AssignAgentHelperAPI::register($app); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
use DBA\Agent; | ||
use DBA\Task; | ||
|
||
require_once(dirname(__FILE__) . "/../common/AbstractHelperAPI.class.php"); | ||
|
||
class UnassignAgentHelperAPI extends AbstractHelperAPI { | ||
public static function getBaseUri(): string { | ||
return "/api/v2/helper/unassignAgent"; | ||
} | ||
|
||
public static function getAvailableMethods(): array { | ||
return ['POST']; | ||
} | ||
|
||
public function getRequiredPermissions(string $method): array { | ||
return [Agent::PERM_UPDATE, Task::PERM_UPDATE]; | ||
} | ||
|
||
public function getFormFields(): array { | ||
return [ | ||
Agent::AGENT_ID => ["type" => "int"], | ||
]; | ||
} | ||
|
||
public function actionPost($data): array|null { | ||
AgentUtils::assign($data[Agent::AGENT_ID], 0, $this->getCurrentUser()); | ||
|
||
# TODO: Check how to handle custom return messages that are not object, probably we want that to be in some kind of standardized form. | ||
return ["unassign" => "success"]; | ||
} | ||
} | ||
|
||
UnassignAgentHelperAPI::register($app); |