Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
33 changes: 33 additions & 0 deletions msa_sdk/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,39 @@ def command_synchronize(self, timeout: int) -> None:

self._call_post(timeout=timeout)

def command_synchronize_async(self) -> None:
"""

Command synchronize Async.

Returns
-------
None

"""
self.action = 'Command synchronize'
self.path = '{}/synchronize/{}?isAsync=true&importWithSameAndUpperRank=true'.format(self.api_path,
self.device_id)

self._call_post()

def get_synchronize_status(self):
"""

Get synchronize Status.

Returns
--------
Dict() with synchronize status

"""
self.action = 'Get synchronize Status'
self.path = '{}/synchronize/status?deviceId={}'.format(self.api_path,
self.device_id)

self._call_get()
return json.loads(self.content)

def command_synchronizeOneOrMoreObjectsFromDevice(self,
mservice_uris: list,
timeout: int) -> None:
Expand Down
76 changes: 53 additions & 23 deletions msa_sdk/repository.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Module Repository."""


import json
import re
from urllib.parse import urlencode

from msa_sdk.msa_api import MSA_API
Expand Down Expand Up @@ -55,21 +56,20 @@ def get_microservice_variables(self, file_uri):
Dictionary wich contains microservice variables definition

"""
import json
self.action = 'Get variables for microservice'
url_encoded = urlencode({'uri': file_uri})
self.path = "{}/resource/variables?{}".format(
self.api_path_v2, url_encoded)
self._call_get()
return json.loads(self.content)

def post_repository_variables(self, respository_uri):
def post_repository_variables(self, repository_uri):
"""
Get repository variables.

Parameters
----------
repository: String
repository_uri: String
File path repository variables

Returns
Expand All @@ -78,7 +78,7 @@ def post_repository_variables(self, respository_uri):

"""
self.action = 'Post repository variables'
url_encoded = urlencode({'repository': respository_uri})
url_encoded = urlencode({'repository': repository_uri})

self.path = "{}/variables?{}".format(self.api_path_v2, url_encoded)
self._call_post()
Expand All @@ -99,7 +99,6 @@ def get_microservice_details(self, file_uri):
Dictionary wich contains microservice details

"""
import json
self.action = 'Get details for microservice'
url_encoded = urlencode({'uri': file_uri})

Expand All @@ -115,9 +114,6 @@ def put_microservice_details(self, microservice_details):

Parameters
----------
file_uri: String
File path to microservice in repository

microservice_details: json
JSON body of microservices detail

Expand Down Expand Up @@ -178,17 +174,14 @@ def get_microservice_path_by_name(self, microservice_name: str,
Parameters
----------
microservice_name: Name of microservice
depoloyment_settings_id: Deployment settings id
deployment_settings_id: Deployment settings id

Returns
-------
String: string
Microservice file path or None

"""
import json
import re

self.action = 'Get deployment settings'

self.path = "/conf-profile/v2/{}".format(deployment_settings_id)
Expand Down Expand Up @@ -230,14 +223,13 @@ def detach_microserviceis_from_configuration_profile(

Parameters
----------
depoloyment_settings_id: Deployment settings id
deployment_settings_id: Deployment settings id
ms_list: List of microservice's URI to detach
Returns
-------
None

"""
import json
self.action = 'Detach microservice from deployment settings'
self.path = "/conf-profile/v2/detach/{}/repository/files".format(
deployment_settings_id)
Expand All @@ -257,7 +249,6 @@ def get_workflow_definition(self, file_uri: str) -> dict:
Variables and their default values

"""
import json
url_encoded = urlencode({'uri': file_uri})
self.action = 'Get workflow definition'
self.path = "/repository/v2/resource/workflow?{}".format(url_encoded)
Expand All @@ -280,7 +271,6 @@ def change_workflow_definition(
None

"""
import json
url_encoded = urlencode({'uri': file_uri})
self.action = 'Change workflow definition'
self.path = "/repository/v2/resource/workflow?{}".format(url_encoded)
Expand Down Expand Up @@ -351,10 +341,10 @@ def create_workflow_definition(
]
}
]
}
}
'''
workflow_definition_dict = json.loads(workflow_definition) #convert string into dict

Returns
-------
None if no error, else it return the error
Expand All @@ -366,11 +356,11 @@ def create_workflow_definition(
for process_details in workflow_definition_dict['process']:
if not process_details['tasks']:
process_details['tasks'] = list()
self._call_post(workflow_definition_dict)

self._call_post(workflow_definition_dict)
return None

def delete_workflow_definition(self, file_uri: str) -> dict:
def delete_workflow_definition(self, file_uri: str) -> None:
"""
Delete Workflow resource.

Expand Down Expand Up @@ -405,9 +395,49 @@ def get_file(self, file_uri):
Dictionary wich contains file content

"""
import json
self.action = 'Get file content'
url_encoded = urlencode({'uri': file_uri})
self.path = "{}/file?{}".format(self.api_path, url_encoded)
self._call_get()
return json.loads(self.content)

def add_file(self, file_uri, content):
"""
Add file content.

Parameters
----------
file_uri: String
File path in repository
content: String
File content

Returns
-------
None

"""
self.action = 'Add file content'
url_encoded = urlencode({'uri': file_uri})
self.path = "{}/file?{}".format(self.api_path, url_encoded)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this API should be deprecated, and we should use a real upload API with multipart content. This method may pose serious problem with bianry content.

Copy link
Contributor Author

@PrasadhNanjundan05 PrasadhNanjundan05 May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API is used in WF file editor, BPM editor .. since those are from editor, I guess we cannot use mulipart content. probably we can limit the content size, sanitize the input path and other security checks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably I guess we should restrict this kind of API to be only allowed to call only from our UI. not directly, just thinking out loud

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean, is we are going to propose a add_file api, the idea is to do it correctly. The fact that UI is using this buggy API is another problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:
I am note sure for UI.
Every people on UI should know that you upload things with multi part, so having a 100% in house way to upload things seems to be more a problem than a solution.

I think UI libraries should as default be compatible with multi part upload.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vignaudo I created a ticket to address this in the next release - https://jiras.ubiqube.com/browse/MSA-14797

content_dict = {'content': content}
self._call_post(content_dict)

def add_directory(self, uri):
"""
Add directory.

Parameters
----------
uri: String
Directory path in repository

Returns
-------
None

"""
self.action = 'Add directory'
url_encoded = urlencode({'uri': uri})
self.path = "{}/directory?{}".format(self.api_path, url_encoded)
self._call_post()