Skip to content

Commit

Permalink
Merge pull request #44 from Onemind-Services-LLC/marketplace.jps
Browse files Browse the repository at this point in the history
added marketplace.jps
  • Loading branch information
abhi1693 authored Dec 24, 2023
2 parents 2e0176d + e98e5cc commit 2fede33
Show file tree
Hide file tree
Showing 3 changed files with 278 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/marketplace.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ Marketplace
:members:
:undoc-members:
:show-inheritance:

.. automodule:: jelastic.api.marketplace._Jps
:members:
:undoc-members:
:show-inheritance:
145 changes: 145 additions & 0 deletions jelastic/api/marketplace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ def Installation(self) -> "_Installation":
debug=self._debug,
)

@property
def Jps(self) -> "_Jps":
"""
The JPS service provides methods for working with custom JPS manifests.
>>> from jelastic import Jelastic
>>> jelastic = Jelastic('https://jca.xapp.cloudmydc.com', token='d6f4e314a5b5fefd164995169f28ae32d987704f')
>>> jelastic.marketplace.Jps
Ref: https://docs.jelastic.com/api/private/#!/api/marketplace.Jps
"""
return _Jps(
session=self._session,
token=self._token,
debug=self._debug,
)


class _Installation(Marketplace):
"""
Expand Down Expand Up @@ -611,3 +626,133 @@ def UpdateAppVisibilityLevels(
"visibilityLevels": visibility_levels,
},
)


class _Jps(Marketplace):
"""
Ref: https://docs.jelastic.com/api/private/#!/api/marketplace.Jps
"""

_endpoint2 = "jps"

def ExecuteAppAction(
self,
app_unique_name: str,
action: list[str] = None,
settings_id: list[str] = None,
params: list[str] = None,
lang: list[str] = None,
):
return self._get(
"ExecuteAppAction",
params={
"appUniqueName": app_unique_name,
"action": action,
"settingsId": settings_id,
"params": params,
"lang": lang,
},
delimiter=",",
)

def GetAppInfo(
self,
jps: list[str] = None,
lang: list[str] = None,
owner_uid: list[str] = None,
):
"""
param jps: custom JPS (manifest body, link, or application ID from the Marketplace).
param lang: target installation language.
param owner_uid: unique identifier of the target user account.
"""
return self._get(
"GetAppInfo",
params={
"jps": jps,
"lang": lang,
"ownerUid": owner_uid,
},
delimiter=",",
)

def GetAppSettings(
self,
app_unique_name: str,
settings_id: list[str] = None,
lang: list[str] = None,
):
return self._get(
"GetAppSettings",
params={
"appUniqueName": app_unique_name,
"settingsId": settings_id,
"lang": lang,
},
delimiter=",",
)

def GetEngineVersion(self):
return self._get("GetEngineVersion", params={})

def GetScriptingAppid(self):
return self._get("GetScriptingAppid", params={})

def Install(
self,
jps: str,
env_name: list[str] = None,
settings: list[str] = None,
node_group: list[str] = None,
display_name: list[str] = None,
region: list[str] = None,
env_groups: list[str] = None,
owner_uid: list[int] = None,
logs_path: list[str] = None,
write_output_tasks: list[bool] = None,
skip_node_emails: list[bool] = None,
):
"""
param jps: custom JPS (manifest body, link, or application ID from the Marketplace).
param env_name: target environment name.
param settings: JSON object with custom settings for the JPS manifest.
param node_group: unique identifier of the target node group (layer), e.g. “cp” for the default application server layer.
param display_name: custom alias (display name) for the deployed JPS application.
param region: target environment region.
param env_groups: target environment group name or JSON array of group names.
param owner_uid: unique identifier of the target user account.
param logs_path: a relative path to the JPS installation log file, which is created in the user's application in the Backend-as-a-Service system. 'cs.log' by default.
param write_output_tasks: defines whether write internal installation events (true) or not (false). It is used with the nested manifest installations.
param skip_node_emails: defines whether to send emails after the new nodes creation (false) or not (true).
"""
return self._get(
"Install",
params={
"jps": jps,
"envName": env_name,
"settingsId": settings,
"nodeGroup": node_group,
"displayName": display_name,
"region": region,
"envGroups": env_groups,
"ownerUid": owner_uid,
"logsPath": logs_path,
"writeOutputTasks": write_output_tasks,
"skipNodeEmails": skip_node_emails,
},
delimiter=",",
)

def Uninstall(
self,
app_unique_name: str,
force: list[bool] = None,
):
return self._get(
"Uninstall",
params={
"appUniqueName": app_unique_name,
"force": force,
},
delimiter=",",
)
128 changes: 128 additions & 0 deletions tests/unit/test_api/test_marketplace/test_jps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
from . import *


def test_execute_app_action(client):
client._get.return_value = success_response
response = client.Jps.ExecuteAppAction(
"app_unique_name",
["action1", "action2"],
["settings_id1", "settings_id2"],
["params1", "params2"],
["lang1", "lang2"],
)
client._get.assert_called_with(
"ExecuteAppAction",
params={
"appUniqueName": "app_unique_name",
"action": ["action1", "action2"],
"settingsId": ["settings_id1", "settings_id2"],
"params": ["params1", "params2"],
"lang": ["lang1", "lang2"],
},
delimiter=",",
)
assert response == success_response


def test_get_app_info(client):
client._get.return_value = success_response
response = client.Jps.GetAppInfo(
["jps1", "jps2"],
["lang1", "lang2"],
["owner_uid1", "owner_uid2"],
)
client._get.assert_called_with(
"GetAppInfo",
params={
"jps": ["jps1", "jps2"],
"lang": ["lang1", "lang2"],
"ownerUid": ["owner_uid1", "owner_uid2"],
},
delimiter=",",
)
assert response == success_response


def test_get_app_settings(client):
client._get.return_value = success_response
response = client.Jps.GetAppSettings(
"app_unique_name",
["settings_id1", "settings_id2"],
["lang1", "lang2"],
)
client._get.assert_called_with(
"GetAppSettings",
params={
"appUniqueName": "app_unique_name",
"settingsId": ["settings_id1", "settings_id2"],
"lang": ["lang1", "lang2"],
},
delimiter=",",
)
assert response == success_response


def test_get_engine_version(client):
client._get.return_value = success_response
response = client.Jps.GetEngineVersion()
client._get.assert_called_with("GetEngineVersion", params={})
assert response == success_response


def test_get_scripting_appid(client):
client._get.return_value = success_response
response = client.Jps.GetScriptingAppid()
client._get.assert_called_with("GetScriptingAppid", params={})
assert response == success_response


def test_install(client):
client._get.return_value = success_response
response = client.Jps.Install(
"jps",
["env_name1", "env_name2"],
["settings1", "settings2"],
["node_group1", "node_group2"],
["display_name1", "display_name2"],
["region1", "region2"],
["env_groups1", "env_groups2"],
[1, 1],
["logs_path1", "logs_path2"],
[True, True],
[True, True],
)
client._get.assert_called_with(
"Install",
params={
"jps": "jps",
"envName": ["env_name1", "env_name2"],
"settingsId": ["settings1", "settings2"],
"nodeGroup": ["node_group1", "node_group2"],
"displayName": ["display_name1", "display_name2"],
"region": ["region1", "region2"],
"envGroups": ["env_groups1", "env_groups2"],
"ownerUid": [1, 1],
"logsPath": ["logs_path1", "logs_path2"],
"writeOutputTasks": [True, True],
"skipNodeEmails": [True, True],
},
delimiter=",",
)
assert response == success_response


def test_uninstall(client):
client._get.return_value = success_response
response = client.Jps.Uninstall(
"app_unique_name",
[True, False],
)
client._get.assert_called_with(
"Uninstall",
params={
"appUniqueName": "app_unique_name",
"force": [True, False],
},
delimiter=",",
)
assert response == success_response

0 comments on commit 2fede33

Please sign in to comment.