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 24
    • Issues 24
    • 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
  • !80
An error occurred while fetching the assigned milestone of the selected merge_request.

Resolve "[Orchestrator] - Create a librabry in core orchestrator"

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged Alexa Oana eliza requested to merge 73-orchestrator-create-a-librabry-in-core-orchestrator into dev 1 month ago
  • Overview 0
  • Commits 22
  • Pipelines 17
  • Changes 2

Related to #73

Viewing commit b64f5b3e
Prev Next
Show latest version
2 files
+ 28
− 10

    Preferences

    File browser
    Compare changes
  • b64f5b3e
    dockx thibault
    :sparkles: feat(archive) - enhance Archive functionality with WebServiceCall... · b64f5b3e
    dockx thibault authored 1 month ago
    :sparkles: feat(archive) - enhance Archive functionality with WebServiceCall integration and improved error handling
.idea/.gitignore 0 → 100755
+ 8
− 0
  • View file @ b64f5b3e

  • Edit in single-file editor

  • Open in Web IDE

# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
plugins/tasks/Archive.php
+ 20
− 10
  • View file @ b64f5b3e

  • Edit in single-file editor

  • Open in Web IDE


<?php
use FusionDirectory\Rest\WebServiceCall;
class Archive implements EndpointInterface
{
private TaskGateway $gateway;
@@ -30,11 +32,6 @@ class Archive implements EndpointInterface
$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)) {
@@ -42,19 +39,32 @@ class Archive implements EndpointInterface
$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]);
// Construct the archive URL
$archiveUrl = $_ENV['FUSION_DIRECTORY_API_URL'] . '/archive/user/' . rawurlencode($task['fdtasksgranulardn'][0]);
// Initialize the WebServiceCall object
$webServiceCall = new WebServiceCall($archiveUrl, 'POST');
$webServiceCall->setCurlSettings();
// Update the task status based on the result
if ($archiveResult === TRUE) {
// Execute the request
$response = curl_exec($webServiceCall->ch);
// Handle any cURL errors
$webServiceCall->handleCurlError($webServiceCall->ch);
// Decode and process the response
$responseData = json_decode($response, true);
if ($responseData && isset($responseData['success']) && $responseData['success'] === 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
}
// Close the cURL resource
curl_close($webServiceCall->ch);
} else {
$result[$task['dn']]['result'] = "User does not meet the criteria for archiving.";
}
Assignee
Alexa Oana eliza's avatar
Alexa Oana eliza
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 Participants
Reference:
Source branch: 73-orchestrator-create-a-librabry-in-core-orchestrator

Menu

Explore Projects Groups Topics Snippets