Skip to content
GitLab
    • Explore Projects Groups Topics Snippets
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • fusiondirectory-orchestrator fusiondirectory-orchestrator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 23
    • Issues 23
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • fusiondirectoryfusiondirectory
  • fusiondirectory-orchestratorfusiondirectory-orchestrator
  • Merge requests
  • !79

Resolve "[Orchestrator] - Automatic Archiving Based on SupAnn Resource States"

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged dockx thibault requested to merge 74-orchestrator-automatic-archiving-based-on-supann-resource-states into dev 1 month ago
  • Overview 0
  • Commits 6
  • Pipelines 6
  • Changes 1

Related to #74 (closed)

Viewing commit 164739c0
Prev Next
Show latest version
1 file
+ 98
− 0

    Preferences

    File browser
    Compare changes
  • Verified
    164739c0
    dockx thibault
    :sparkles: feat(archive) - implement Archive endpoint with GET, PATCH, POST, and DELETE methods · 164739c0
    dockx thibault authored 1 month ago
plugins/tasks/Archive.php 0 → 100644
+ 98
− 0
  • View file @ 164739c0

  • Edit in single-file editor

  • Open in Web IDE

 
<?php
 
 
class Archive implements EndpointInterface
 
{
 
private TaskGateway $gateway;
 
 
public function __construct(TaskGateway $gateway)
 
{
 
$this->gateway = $gateway;
 
}
 
 
/**
 
* @return array
 
* Part of the interface of orchestrator plugin to treat GET method
 
*/
 
public function processEndPointGet(): array
 
{
 
// Retrieve tasks of type 'archive'
 
return $this->gateway->getObjectTypeTask('archive');
 
}
 
 
/**
 
* @param array|null $data
 
* @return array
 
* @throws Exception
 
* Note: Part of the interface of orchestrator plugin to treat PATCH method
 
*/
 
public function processEndPointPatch(array $data = NULL): array
 
{
 
$result = [];
 
$archiveTasks = $this->gateway->getObjectTypeTask('archive');
 
 
// Initialize the webservice object
 
// TODO
 
$webservice = new FusionDirectory\Rest\WebServiceCall($_ENV['FUSION_DIRECTORY_API_URL'] . '/archive', 'POST');
 
$webservice->setCurlSettings();
 
 
foreach ($archiveTasks as $task) {
 
// Verify the task status and schedule
 
if ($this->gateway->statusAndScheduleCheck($task)) {
 
// Retrieve the user's supannAccountStatus
 
$userStatus = $this->getUserSupannAccountStatus($task['fdtasksgranulardn'][0]);
 
 
// Check if the user meets the "toBeArchived" condition
 
// TODO
 
if ($userStatus === 'toBeArchived') {
 
// Trigger the archive method via the webservice
 
$archiveResult = $webservice->triggerArchive($task['fdtasksgranulardn'][0]);
 
 
// Update the task status based on the result
 
if ($archiveResult === TRUE) {
 
$result[$task['dn']]['result'] = "User successfully archived.";
 
$this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '2'); // Mark task as completed
 
} else {
 
$result[$task['dn']]['result'] = "Error archiving user.";
 
$this->gateway->updateTaskStatus($task['dn'], $task['cn'][0], '3'); // Mark task as failed
 
}
 
} else {
 
$result[$task['dn']]['result'] = "User does not meet the criteria for archiving.";
 
}
 
}
 
}
 
 
return $result;
 
}
 
 
/**
 
* @param array|null $data
 
* @return array
 
* Note: Part of the interface of orchestrator plugin to treat POST method
 
*/
 
public function processEndPointPost(array $data = NULL): array
 
{
 
return [];
 
}
 
 
/**
 
* @param array|null $data
 
* @return array
 
* Note: Part of the interface of orchestrator plugin to treat DELETE method
 
*/
 
public function processEndPointDelete(array $data = NULL): array
 
{
 
return [];
 
}
 
 
/**
 
* Retrieve the supannAccountStatus of a user
 
* @param string $userDn
 
* @return string|null
 
*/
 
private function getUserSupannAccountStatus(string $userDn): ?string
 
{
 
// Logic to retrieve the supannAccountStatus attribute of the user
 
$user = $this->gateway->getLdapEntry($userDn, ['supannAccountStatus']);
 
return $user['supannAccountStatus'][0] ?? NULL;
 
}
 
}
 
\ No newline at end of file
Assignee
dockx thibault's avatar
dockx thibault
Assign to
0 Reviewers
None
Request review from
Labels
2
PJ1802-0188 gendarmerie
2
PJ1802-0188 gendarmerie
    Assign labels
  • Manage project labels

Milestone
FusionDirectory Orchestrator 1.2
FusionDirectory Orchestrator 1.2 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 Participant
dockx thibault
Reference: fusiondirectory/fusiondirectory-orchestrator!79
Source branch: 74-orchestrator-automatic-archiving-based-on-supann-resource-states

Menu

Explore Projects Groups Topics Snippets