cmem-plugin-packages 0.9.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cmem_plugin_packages/__init__.py +1 -0
- cmem_plugin_packages/build_packages.py +136 -0
- cmem_plugin_packages/icons/marketplace-build.svg +1 -0
- cmem_plugin_packages/icons/marketplace-install.svg +1 -0
- cmem_plugin_packages/icons/marketplace-publish.svg +21 -0
- cmem_plugin_packages/icons/marketplace-uninstall.svg +1 -0
- cmem_plugin_packages/install_packages.py +366 -0
- cmem_plugin_packages/package_parameter.py +82 -0
- cmem_plugin_packages/publish_packages.py +117 -0
- cmem_plugin_packages/uninstall_packages.py +296 -0
- cmem_plugin_packages-0.9.0.dist-info/METADATA +47 -0
- cmem_plugin_packages-0.9.0.dist-info/RECORD +14 -0
- cmem_plugin_packages-0.9.0.dist-info/WHEEL +4 -0
- cmem_plugin_packages-0.9.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""cmem-plugin-packages"""
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""Build Marketplace packages from a cpa-manifest.json file"""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Sequence
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
|
6
|
+
|
|
7
|
+
from cmem_client.client import Client
|
|
8
|
+
from cmem_client.eccenca_marketplace_client.models.files import (
|
|
9
|
+
GraphFileSpec,
|
|
10
|
+
ImageFileSpec,
|
|
11
|
+
ProjectFileSpec,
|
|
12
|
+
TextFileSpec,
|
|
13
|
+
)
|
|
14
|
+
from cmem_client.eccenca_marketplace_client.package_version import PackageVersion
|
|
15
|
+
from cmem_plugin_base.dataintegration.client import get_client
|
|
16
|
+
from cmem_plugin_base.dataintegration.context import ExecutionContext, ExecutionReport
|
|
17
|
+
from cmem_plugin_base.dataintegration.description import Icon, Plugin, PluginParameter
|
|
18
|
+
from cmem_plugin_base.dataintegration.entity import Entities, Entity
|
|
19
|
+
from cmem_plugin_base.dataintegration.parameter.multiline import MultilineStringParameterType
|
|
20
|
+
from cmem_plugin_base.dataintegration.plugins import WorkflowPlugin
|
|
21
|
+
from cmem_plugin_base.dataintegration.ports import FixedNumberOfInputs, FixedSchemaPort
|
|
22
|
+
from cmem_plugin_base.dataintegration.typed_entities.file import FileEntitySchema, LocalFile
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@Plugin(
|
|
26
|
+
label="Build Packages",
|
|
27
|
+
plugin_id="cmem_plugin_packages-BuildPackages",
|
|
28
|
+
description="Build CPA packages from a cpa-manifest.json file. "
|
|
29
|
+
"Uses graphs, projects and auxiliary files from this CMEM instance.",
|
|
30
|
+
documentation="""
|
|
31
|
+
Build a CPA package from a manifest JSON file.
|
|
32
|
+
|
|
33
|
+
The manifest specifies which graphs, projects and auxiliary files to include.
|
|
34
|
+
Graphs are exported from the store, projects from the workspace, and
|
|
35
|
+
auxiliary files (text, image) from the current project's file resources.
|
|
36
|
+
|
|
37
|
+
The built package archives (*.cpa) are provided on the output port, e.g. to be
|
|
38
|
+
consumed by the Publish Packages or Install Packages task.
|
|
39
|
+
""",
|
|
40
|
+
icon=Icon(file_name="icons/marketplace-build.svg", package=__package__),
|
|
41
|
+
actions=[],
|
|
42
|
+
parameters=[
|
|
43
|
+
PluginParameter(
|
|
44
|
+
name="manifest_file",
|
|
45
|
+
label="Manifest JSON",
|
|
46
|
+
description="The manifest JSON. If provided, the package is built from this "
|
|
47
|
+
"manifest and the input port is removed. If left empty, the manifest files "
|
|
48
|
+
"are taken from the input port.",
|
|
49
|
+
param_type=MultilineStringParameterType(),
|
|
50
|
+
default_value="",
|
|
51
|
+
)
|
|
52
|
+
],
|
|
53
|
+
)
|
|
54
|
+
class BuildMarketplacePackages(WorkflowPlugin):
|
|
55
|
+
"""Build Marketplace packages from a cpa-manifest.json file"""
|
|
56
|
+
|
|
57
|
+
def __init__(self, manifest_file: str):
|
|
58
|
+
self.manifest_file = manifest_file
|
|
59
|
+
self.input_ports = (
|
|
60
|
+
FixedNumberOfInputs([FixedSchemaPort(schema=FileEntitySchema())])
|
|
61
|
+
if manifest_file == ""
|
|
62
|
+
else FixedNumberOfInputs([])
|
|
63
|
+
)
|
|
64
|
+
self.output_port = FixedSchemaPort(schema=FileEntitySchema())
|
|
65
|
+
|
|
66
|
+
def execute(self, inputs: Sequence[Entities], context: ExecutionContext) -> Entities | None:
|
|
67
|
+
"""Execute the workflow"""
|
|
68
|
+
cmem_client = get_client(context=context)
|
|
69
|
+
|
|
70
|
+
project_id = context.task.project_id()
|
|
71
|
+
file_schema = FileEntitySchema()
|
|
72
|
+
output_entities = []
|
|
73
|
+
|
|
74
|
+
if self.manifest_file == "":
|
|
75
|
+
for entity in inputs[0].entities:
|
|
76
|
+
manifest_file = file_schema.from_entity(entity)
|
|
77
|
+
manifest_json = manifest_file.read_text(context=context)
|
|
78
|
+
output_entities.append(self._build_cpa(manifest_json, cmem_client, project_id))
|
|
79
|
+
else:
|
|
80
|
+
manifest_json = self.manifest_file
|
|
81
|
+
output_entities.append(self._build_cpa(manifest_json, cmem_client, project_id))
|
|
82
|
+
|
|
83
|
+
count = len(output_entities)
|
|
84
|
+
context.report.update(
|
|
85
|
+
ExecutionReport(
|
|
86
|
+
entity_count=count,
|
|
87
|
+
operation="Build",
|
|
88
|
+
operation_desc=f"package archive{'s' if count > 1 else ''} created",
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
return Entities(entities=iter(output_entities), schema=file_schema)
|
|
93
|
+
|
|
94
|
+
@staticmethod
|
|
95
|
+
def _build_cpa(
|
|
96
|
+
manifest_json: str,
|
|
97
|
+
cmem_client: Client,
|
|
98
|
+
project_id: str,
|
|
99
|
+
) -> Entity:
|
|
100
|
+
"""Build a single CPA archive from a manifest JSON string."""
|
|
101
|
+
package_version = PackageVersion.from_json(manifest_json)
|
|
102
|
+
manifest = package_version.manifest
|
|
103
|
+
|
|
104
|
+
cpa_filename = f"{manifest.package_id}-v{manifest.package_version}.cpa"
|
|
105
|
+
with NamedTemporaryFile(suffix=".cpa", delete=False, prefix=cpa_filename) as out_file:
|
|
106
|
+
out_path = Path(out_file.name)
|
|
107
|
+
|
|
108
|
+
with TemporaryDirectory() as tmp_dir:
|
|
109
|
+
tmp = Path(tmp_dir)
|
|
110
|
+
|
|
111
|
+
for file_spec in manifest.files:
|
|
112
|
+
target_path = tmp / file_spec.file_path
|
|
113
|
+
target_path.parent.mkdir(parents=True, exist_ok=True)
|
|
114
|
+
|
|
115
|
+
if isinstance(file_spec, GraphFileSpec):
|
|
116
|
+
cmem_client.graphs.export_item(
|
|
117
|
+
key=str(file_spec.graph_iri),
|
|
118
|
+
path=target_path,
|
|
119
|
+
replace=True,
|
|
120
|
+
)
|
|
121
|
+
elif isinstance(file_spec, ProjectFileSpec):
|
|
122
|
+
cmem_client.projects.export_item(
|
|
123
|
+
key=file_spec.project_id,
|
|
124
|
+
path=target_path,
|
|
125
|
+
replace=True,
|
|
126
|
+
)
|
|
127
|
+
elif isinstance(file_spec, (TextFileSpec, ImageFileSpec)):
|
|
128
|
+
cmem_client.files.export_item(
|
|
129
|
+
key=f"{project_id}:{file_spec.file_path}",
|
|
130
|
+
path=target_path,
|
|
131
|
+
replace=True,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
PackageVersion(manifest=manifest, directory=tmp).build_archive(archive=out_path)
|
|
135
|
+
|
|
136
|
+
return FileEntitySchema().to_entity(LocalFile(path=str(out_path)))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C11.8 2 11.6 2.1 11.4 2.2L3.5 6.6C3.2 6.8 3 7.1 3 7.5V16.5C3 16.9 3.2 17.2 3.5 17.4L11.4 21.8C11.6 21.9 11.8 22 12 22S12.4 21.9 12.6 21.8L13.5 21.3C13.2 20.7 13.1 20 13 19.3V12.6L19 9.2V13C19.7 13 20.4 13.1 21 13.3V7.5C21 7.1 20.8 6.8 20.5 6.6L12.6 2.2C12.4 2.1 12.2 2 12 2M12 4.2L18 7.5L16 8.6L10.1 5.2L12 4.2M8.1 6.3L14 9.8L12 10.9L6 7.5L8.1 6.3M5 9.2L11 12.6V19.3L5 15.9V9.2M21.3 15.8L17.7 19.4L16.1 17.8L15 19L17.8 22L22.6 17.2L21.3 15.8Z" /></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 19.3V12.6L19 9.2V13C19.7 13 20.4 13.1 21 13.4V7.5C21 7.1 20.8 6.8 20.5 6.6L12.6 2.2C12.4 2.1 12.2 2 12 2S11.6 2.1 11.4 2.2L3.5 6.6C3.2 6.8 3 7.1 3 7.5V16.5C3 16.9 3.2 17.2 3.5 17.4L11.4 21.8C11.6 21.9 11.8 22 12 22S12.4 21.9 12.6 21.8L13.5 21.3C13.2 20.7 13.1 20 13 19.3M12 4.2L18 7.5L16 8.6L10.1 5.2L12 4.2M11 19.3L5 15.9V9.2L11 12.6V19.3M12 10.8L6 7.5L8 6.3L14 9.8L12 10.8M20 15V18H23V20H20V23H18V20H15V18H18V15H20Z" /></svg>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
2
|
+
<title>package-upload</title>
|
|
3
|
+
|
|
4
|
+
<!-- Mask -->
|
|
5
|
+
<mask id="cut">
|
|
6
|
+
<rect width="24" height="24" fill="white"/>
|
|
7
|
+
|
|
8
|
+
<!-- Circle EXACTLY centered on arrow -->
|
|
9
|
+
<circle cx="17" cy="18" r="4.5" fill="black"/>
|
|
10
|
+
</mask>
|
|
11
|
+
|
|
12
|
+
<!-- Package -->
|
|
13
|
+
<path mask="url(#cut)"
|
|
14
|
+
d="M21,16.5C21,16.88 20.79,17.21 20.47,17.38L12.57,21.82C12.41,21.94 12.21,22 12,22C11.79,22 11.59,21.94 11.43,21.82L3.53,17.38C3.21,17.21 3,16.88 3,16.5V7.5C3,7.12 3.21,6.79 3.53,6.62L11.43,2.18C11.59,2.06 11.79,2 12,2C12.21,2 12.41,2.06 12.57,2.18L20.47,6.62C20.79,6.79 21,7.12 21,7.5V16.5M12,4.15L10.11,5.22L16,8.61L17.96,7.5L12,4.15M6.04,7.5L12,10.85L13.96,9.75L8.08,6.35L6.04,7.5M5,15.91L11,19.29V12.58L5,9.21V15.91M19,15.91V9.21L13,12.58V19.29L19,15.91Z" />
|
|
15
|
+
|
|
16
|
+
<!-- Upload arrow (same center as circle) -->
|
|
17
|
+
<g transform="translate(8.8,9.5) scale(0.7)">
|
|
18
|
+
<path d="M8 17V15H16V17H8M16 10L12 6L8 10H10.5V14H13.5V10H16"/>
|
|
19
|
+
</g>
|
|
20
|
+
|
|
21
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 12.6L19 9.2V13C19.7 13 20.4 13.1 21 13.4V7.5C21 7.1 20.8 6.8 20.5 6.6L12.6 2.2C12.4 2.1 12.2 2 12 2S11.6 2.1 11.4 2.2L3.5 6.6C3.2 6.8 3 7.1 3 7.5V16.5C3 16.9 3.2 17.2 3.5 17.4L11.4 21.8C11.6 21.9 11.8 22 12 22S12.4 21.9 12.6 21.8L13.5 21.3C13.2 20.7 13.1 20 13 19.3M12 4.2L18 7.5L16 8.6L10.1 5.2L12 4.2M11 19.3L5 15.9V9.2L11 12.6V19.3M12 10.8L6 7.5L8 6.3L14 9.8L12 10.8M23 18V20H15V18H23Z" /></svg>
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
"""Marketplace Plugin for installing packages"""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import tempfile
|
|
5
|
+
import zipfile
|
|
6
|
+
from collections import OrderedDict
|
|
7
|
+
from collections.abc import Sequence
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from cmem_client.client import Client
|
|
11
|
+
from cmem_client.repositories.marketplace_packages import (
|
|
12
|
+
MarketplacePackagesImportConfig,
|
|
13
|
+
MarketplacePackagesRepository,
|
|
14
|
+
)
|
|
15
|
+
from cmem_client.repositories.protocols.import_item import ImportConflictPolicy
|
|
16
|
+
from cmem_plugin_base.dataintegration.client import get_client
|
|
17
|
+
from cmem_plugin_base.dataintegration.context import (
|
|
18
|
+
ExecutionContext,
|
|
19
|
+
ExecutionReport,
|
|
20
|
+
PluginContext,
|
|
21
|
+
)
|
|
22
|
+
from cmem_plugin_base.dataintegration.description import Icon, Plugin, PluginAction, PluginParameter
|
|
23
|
+
from cmem_plugin_base.dataintegration.entity import Entities, EntityPath, EntitySchema
|
|
24
|
+
from cmem_plugin_base.dataintegration.parameter.choice import ChoiceParameterType
|
|
25
|
+
from cmem_plugin_base.dataintegration.plugins import WorkflowPlugin
|
|
26
|
+
from cmem_plugin_base.dataintegration.ports import FixedNumberOfInputs, FixedSchemaPort
|
|
27
|
+
from cmem_plugin_base.dataintegration.typed_entities.file import FileEntitySchema
|
|
28
|
+
from cmem_plugin_base.dataintegration.types import BoolParameterType
|
|
29
|
+
|
|
30
|
+
from cmem_plugin_packages.package_parameter import MarketplacePackageParameterType
|
|
31
|
+
|
|
32
|
+
INSTALL_PACKAGE_LIST_SCHEMA = EntitySchema(
|
|
33
|
+
type_uri="",
|
|
34
|
+
paths=[
|
|
35
|
+
EntityPath("package_id"),
|
|
36
|
+
EntityPath("marketplace_url"),
|
|
37
|
+
],
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
DEFAULT_MARKETPLACE_URL = "https://eccenca.market"
|
|
41
|
+
GET_PROJECT_FILES_URL = (
|
|
42
|
+
"https://documentation.eccenca.com/latest/build/reference/customtask/getProjectFiles/"
|
|
43
|
+
)
|
|
44
|
+
GET_NEXTCLOUD_FILES_URL = "https://documentation.eccenca.com/latest/build/reference/customtask/cmem_plugin_nextcloud-Download/"
|
|
45
|
+
IMPORT_CONFLICT_POLICIES: OrderedDict = OrderedDict(
|
|
46
|
+
[
|
|
47
|
+
(ImportConflictPolicy.REPLACE, "Replace"),
|
|
48
|
+
(ImportConflictPolicy.SKIP, "Skip"),
|
|
49
|
+
(ImportConflictPolicy.FAIL, "Fail"),
|
|
50
|
+
]
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@Plugin(
|
|
55
|
+
label="Install Packages",
|
|
56
|
+
plugin_id="cmem_plugin_packages-InstallPackages",
|
|
57
|
+
description="Install packages from a marketplace service or provided package archives.",
|
|
58
|
+
documentation="""Installs packages and their dependencies into Corporate Memory.
|
|
59
|
+
|
|
60
|
+
This task supports three package installation modes (mutually exclusive):
|
|
61
|
+
|
|
62
|
+
1. **Package ID** (default): Installs a single package selected via the
|
|
63
|
+
*Package ID* parameter.
|
|
64
|
+
2. **Package archives from input port**: Installs package archives (*.cpa) which were
|
|
65
|
+
provided by other tasks.
|
|
66
|
+
3. **Package list from input port**: Installs multiple packages, optionally from different
|
|
67
|
+
marketplace services.
|
|
68
|
+
|
|
69
|
+
Use **Preview dependencies** to inspect what will be installed before executing
|
|
70
|
+
(**Package ID** mode only).
|
|
71
|
+
""",
|
|
72
|
+
icon=Icon(file_name="icons/marketplace-install.svg", package=__package__),
|
|
73
|
+
actions=[
|
|
74
|
+
PluginAction(
|
|
75
|
+
name="preview_dependencies",
|
|
76
|
+
label="Preview dependencies",
|
|
77
|
+
description="""Preview the marketplace package dependencies.""",
|
|
78
|
+
)
|
|
79
|
+
],
|
|
80
|
+
parameters=[
|
|
81
|
+
PluginParameter(
|
|
82
|
+
name="package_id",
|
|
83
|
+
label="Package ID",
|
|
84
|
+
description="The identifier of a package from the marketplace.",
|
|
85
|
+
param_type=MarketplacePackageParameterType("", ""),
|
|
86
|
+
default_value="",
|
|
87
|
+
),
|
|
88
|
+
PluginParameter(
|
|
89
|
+
name="import_conflict_policy",
|
|
90
|
+
label="Import conflict policy",
|
|
91
|
+
description="""How to proceed if a package is already installed:
|
|
92
|
+
|
|
93
|
+
- **Replace**: Delete the installed package and install the new one.
|
|
94
|
+
- **Skip**: Leave the installed package untouched and continue with the next one.
|
|
95
|
+
- **Fail**: Abort the task with an error.
|
|
96
|
+
""",
|
|
97
|
+
param_type=ChoiceParameterType(IMPORT_CONFLICT_POLICIES),
|
|
98
|
+
default_value=ImportConflictPolicy.FAIL,
|
|
99
|
+
),
|
|
100
|
+
PluginParameter(
|
|
101
|
+
name="install_from_input_files",
|
|
102
|
+
label="Install package archives (*.cpa) from input port",
|
|
103
|
+
description=f"""If enabled, the task will provide an input port to directly install
|
|
104
|
+
package archives delivered from a previous task in the workflow.
|
|
105
|
+
|
|
106
|
+
The sending task needs to deliver the package archive with the FileEntitySchema (e.g.
|
|
107
|
+
[Get project files]({GET_PROJECT_FILES_URL}) or
|
|
108
|
+
[Download Nextcloud files]({GET_NEXTCLOUD_FILES_URL})).""",
|
|
109
|
+
param_type=BoolParameterType(),
|
|
110
|
+
default_value=False,
|
|
111
|
+
),
|
|
112
|
+
PluginParameter(
|
|
113
|
+
name="install_from_list",
|
|
114
|
+
label="Install listed packages from input port",
|
|
115
|
+
description=f"""If enabled, the task will provide an input port to install a
|
|
116
|
+
package list delivered from a previous task in the workflow.
|
|
117
|
+
|
|
118
|
+
The requested input schema paths are `package_id` (mandatory) and `marketplace_url`
|
|
119
|
+
(optional: defaults to `{DEFAULT_MARKETPLACE_URL}`).
|
|
120
|
+
""",
|
|
121
|
+
param_type=BoolParameterType(),
|
|
122
|
+
default_value=False,
|
|
123
|
+
),
|
|
124
|
+
PluginParameter(
|
|
125
|
+
name="ignore_dependencies",
|
|
126
|
+
label="Ignore dependencies",
|
|
127
|
+
description="If enabled, package dependencies are not installed.",
|
|
128
|
+
param_type=BoolParameterType(),
|
|
129
|
+
default_value=False,
|
|
130
|
+
advanced=True,
|
|
131
|
+
),
|
|
132
|
+
PluginParameter(
|
|
133
|
+
name="marketplace_url",
|
|
134
|
+
label="Marketplace URL",
|
|
135
|
+
description="The URL of the marketplace server from which packages are installed.",
|
|
136
|
+
default_value=DEFAULT_MARKETPLACE_URL,
|
|
137
|
+
),
|
|
138
|
+
PluginParameter(
|
|
139
|
+
name="use_cache",
|
|
140
|
+
label="Use cache",
|
|
141
|
+
description="If enabled, uses the local marketplace package cache. "
|
|
142
|
+
"Disabled by default, as write access to the file system may not be available.",
|
|
143
|
+
param_type=BoolParameterType(),
|
|
144
|
+
default_value=False,
|
|
145
|
+
advanced=True,
|
|
146
|
+
),
|
|
147
|
+
],
|
|
148
|
+
)
|
|
149
|
+
class InstallMarketplacePackages(WorkflowPlugin):
|
|
150
|
+
"""Install Marketplace packages from the marketplace server"""
|
|
151
|
+
|
|
152
|
+
def __init__( # noqa: PLR0913
|
|
153
|
+
self,
|
|
154
|
+
package_id: str,
|
|
155
|
+
import_conflict_policy: ImportConflictPolicy,
|
|
156
|
+
install_from_input_files: bool,
|
|
157
|
+
install_from_list: bool,
|
|
158
|
+
ignore_dependencies: bool,
|
|
159
|
+
marketplace_url: str,
|
|
160
|
+
use_cache: bool,
|
|
161
|
+
):
|
|
162
|
+
if install_from_input_files and install_from_list:
|
|
163
|
+
raise ValueError("Both input port options cannot be used together. Please choose one.")
|
|
164
|
+
|
|
165
|
+
if not install_from_list and not install_from_input_files and package_id == "":
|
|
166
|
+
raise ValueError(
|
|
167
|
+
"Please provide a package ID or use one of the input port installation options."
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
if install_from_list and package_id != "":
|
|
171
|
+
raise ValueError(
|
|
172
|
+
"Cannot install from a specified package ID and a list at the same time. "
|
|
173
|
+
"Please choose one."
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
if install_from_input_files and package_id != "":
|
|
177
|
+
raise ValueError(
|
|
178
|
+
"Cannot install from a specified package ID and provided files at the same time. "
|
|
179
|
+
"Please choose one."
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
self.package_id = package_id
|
|
183
|
+
self.import_conflict_policy = import_conflict_policy
|
|
184
|
+
self.install_from_input_file = install_from_input_files
|
|
185
|
+
self.install_from_list = install_from_list
|
|
186
|
+
self.ignore_dependencies = ignore_dependencies
|
|
187
|
+
self.marketplace_url = marketplace_url
|
|
188
|
+
self.use_cache = use_cache
|
|
189
|
+
|
|
190
|
+
if self.install_from_input_file:
|
|
191
|
+
self.input_ports = FixedNumberOfInputs([FixedSchemaPort(schema=FileEntitySchema())])
|
|
192
|
+
elif self.install_from_list:
|
|
193
|
+
self.input_ports = FixedNumberOfInputs(
|
|
194
|
+
[FixedSchemaPort(schema=INSTALL_PACKAGE_LIST_SCHEMA)]
|
|
195
|
+
)
|
|
196
|
+
else:
|
|
197
|
+
self.input_ports = FixedNumberOfInputs([])
|
|
198
|
+
|
|
199
|
+
self.output_port = None
|
|
200
|
+
|
|
201
|
+
def execute(self, inputs: Sequence[Entities], context: ExecutionContext) -> None:
|
|
202
|
+
"""Execute the workflow"""
|
|
203
|
+
cmem_client = get_client(context=context)
|
|
204
|
+
cmem_client.marketplace.marketplace_url = self.marketplace_url
|
|
205
|
+
packages = cmem_client.marketplace_packages
|
|
206
|
+
|
|
207
|
+
import_config = MarketplacePackagesImportConfig(
|
|
208
|
+
ignore_dependencies=self.ignore_dependencies,
|
|
209
|
+
use_cache=self.use_cache,
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
if inputs:
|
|
213
|
+
if self.install_from_input_file:
|
|
214
|
+
self._install_from_file_entity(context, inputs, packages)
|
|
215
|
+
return
|
|
216
|
+
if self.install_from_list:
|
|
217
|
+
self._install_from_list(cmem_client, context, import_config, inputs)
|
|
218
|
+
return
|
|
219
|
+
else:
|
|
220
|
+
self._install_from_parameter(context, import_config, packages)
|
|
221
|
+
return
|
|
222
|
+
|
|
223
|
+
def _install_from_parameter(
|
|
224
|
+
self,
|
|
225
|
+
context: ExecutionContext,
|
|
226
|
+
import_config: MarketplacePackagesImportConfig,
|
|
227
|
+
packages: MarketplacePackagesRepository,
|
|
228
|
+
) -> None:
|
|
229
|
+
context.report.update(
|
|
230
|
+
ExecutionReport(
|
|
231
|
+
entity_count=1,
|
|
232
|
+
operation="Installing",
|
|
233
|
+
operation_desc=f"package installing: {self.package_id}",
|
|
234
|
+
)
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
packages.import_item(
|
|
238
|
+
key=self.package_id,
|
|
239
|
+
configuration=import_config,
|
|
240
|
+
on_conflict=self.import_conflict_policy,
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
context.report.update(
|
|
244
|
+
ExecutionReport(
|
|
245
|
+
entity_count=1,
|
|
246
|
+
operation="Install",
|
|
247
|
+
operation_desc=f"package installed: {self.package_id}",
|
|
248
|
+
)
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
def _install_from_list(
|
|
252
|
+
self,
|
|
253
|
+
cmem_client: Client,
|
|
254
|
+
context: ExecutionContext,
|
|
255
|
+
import_config: MarketplacePackagesImportConfig,
|
|
256
|
+
inputs: Sequence[Entities],
|
|
257
|
+
) -> None:
|
|
258
|
+
entities_input = inputs[0]
|
|
259
|
+
path_names = [p.path for p in entities_input.schema.paths]
|
|
260
|
+
url_index = path_names.index("marketplace_url") if "marketplace_url" in path_names else None
|
|
261
|
+
installed_count = 0
|
|
262
|
+
|
|
263
|
+
for entity in entities_input.entities:
|
|
264
|
+
package_id = entity.values[0][0]
|
|
265
|
+
if url_index is not None and entity.values[url_index]:
|
|
266
|
+
cmem_client.marketplace.marketplace_url = (
|
|
267
|
+
entity.values[url_index][0] or self.marketplace_url
|
|
268
|
+
)
|
|
269
|
+
else:
|
|
270
|
+
cmem_client.marketplace.marketplace_url = self.marketplace_url
|
|
271
|
+
|
|
272
|
+
installed_count += 1
|
|
273
|
+
context.report.update(
|
|
274
|
+
ExecutionReport(
|
|
275
|
+
entity_count=installed_count,
|
|
276
|
+
operation="Installing",
|
|
277
|
+
operation_desc=f"package installing: {package_id}",
|
|
278
|
+
)
|
|
279
|
+
)
|
|
280
|
+
cmem_client.marketplace_packages.import_item(
|
|
281
|
+
key=package_id, on_conflict=self.import_conflict_policy, configuration=import_config
|
|
282
|
+
)
|
|
283
|
+
context.report.update(
|
|
284
|
+
ExecutionReport(
|
|
285
|
+
entity_count=installed_count,
|
|
286
|
+
operation="Install",
|
|
287
|
+
operation_desc=f"package{'s' if installed_count > 1 else ''} installed",
|
|
288
|
+
)
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
def _install_from_file_entity(
|
|
292
|
+
self,
|
|
293
|
+
context: ExecutionContext,
|
|
294
|
+
inputs: Sequence[Entities],
|
|
295
|
+
packages: MarketplacePackagesRepository,
|
|
296
|
+
) -> None:
|
|
297
|
+
file_schema = FileEntitySchema()
|
|
298
|
+
installed_count = 0
|
|
299
|
+
for entity in inputs[0].entities:
|
|
300
|
+
file = file_schema.from_entity(entity)
|
|
301
|
+
with tempfile.NamedTemporaryFile(suffix=".cpa", delete=False) as tmp:
|
|
302
|
+
tmp_path = Path(tmp.name)
|
|
303
|
+
tmp.write(file.read_bytes(context=context))
|
|
304
|
+
|
|
305
|
+
installed_count += 1
|
|
306
|
+
context.report.update(
|
|
307
|
+
ExecutionReport(
|
|
308
|
+
entity_count=installed_count,
|
|
309
|
+
operation="Installing",
|
|
310
|
+
operation_desc=f"package installing: {tmp_path.name}",
|
|
311
|
+
)
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
try:
|
|
315
|
+
local_import_config = MarketplacePackagesImportConfig(
|
|
316
|
+
ignore_dependencies=self.ignore_dependencies,
|
|
317
|
+
use_cache=self.use_cache,
|
|
318
|
+
install_from_marketplace=False,
|
|
319
|
+
)
|
|
320
|
+
packages.import_item(
|
|
321
|
+
path=tmp_path,
|
|
322
|
+
on_conflict=self.import_conflict_policy,
|
|
323
|
+
configuration=local_import_config,
|
|
324
|
+
)
|
|
325
|
+
finally:
|
|
326
|
+
tmp_path.unlink(missing_ok=True)
|
|
327
|
+
context.report.update(
|
|
328
|
+
ExecutionReport(
|
|
329
|
+
entity_count=installed_count,
|
|
330
|
+
operation="Install",
|
|
331
|
+
operation_desc=f"package{'s' if installed_count > 1 else ''} installed",
|
|
332
|
+
)
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
def preview_dependencies(self, context: PluginContext) -> str:
|
|
336
|
+
"""Preview the marketplace package dependencies"""
|
|
337
|
+
preview = ""
|
|
338
|
+
|
|
339
|
+
cmem_client = get_client(context=context)
|
|
340
|
+
cmem_client.marketplace.marketplace_url = self.marketplace_url
|
|
341
|
+
|
|
342
|
+
if self.package_id == "":
|
|
343
|
+
return "Please select a package ID first."
|
|
344
|
+
|
|
345
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
346
|
+
package_path = cmem_client.marketplace.download_package(
|
|
347
|
+
package_id=self.package_id, path=Path(tmpdir)
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
with zipfile.ZipFile(package_path) as zf: # noqa: SIM117
|
|
351
|
+
with zf.open("cpa-manifest.json") as manifest_file:
|
|
352
|
+
manifest = json.load(manifest_file)
|
|
353
|
+
|
|
354
|
+
dependencies = manifest.get("dependencies", [])
|
|
355
|
+
|
|
356
|
+
if not dependencies:
|
|
357
|
+
preview = "No dependencies found."
|
|
358
|
+
else:
|
|
359
|
+
preview += "| Dependency | Type |\n"
|
|
360
|
+
preview += "|------------|------|\n"
|
|
361
|
+
for dep in dependencies:
|
|
362
|
+
dep_name = dep.get("package_id") or dep.get("pypi_id")
|
|
363
|
+
dep_type = dep.get("dependency_type", "")
|
|
364
|
+
preview += f"| {dep_name} | {dep_type} |\n"
|
|
365
|
+
|
|
366
|
+
return preview
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Package parameter for plugin autocompletion of packages from the server"""
|
|
2
|
+
|
|
3
|
+
from typing import Any, ClassVar
|
|
4
|
+
|
|
5
|
+
from cmem_client.client import Client
|
|
6
|
+
from cmem_plugin_base.dataintegration.context import PluginContext
|
|
7
|
+
from cmem_plugin_base.dataintegration.types import Autocompletion, StringParameterType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MarketplacePackageParameterType(StringParameterType):
|
|
11
|
+
"""Package parameter for plugin autocompletion of packages from the server"""
|
|
12
|
+
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
url_expand: str,
|
|
16
|
+
display_name: str,
|
|
17
|
+
) -> None:
|
|
18
|
+
self.url_expand = url_expand
|
|
19
|
+
self.display_name = display_name
|
|
20
|
+
|
|
21
|
+
autocompletion_depends_on_parameters: ClassVar[list[str]] = ["marketplace_url"]
|
|
22
|
+
|
|
23
|
+
allow_only_autocompleted_values = False
|
|
24
|
+
|
|
25
|
+
def autocomplete(
|
|
26
|
+
self,
|
|
27
|
+
query_terms: list[str],
|
|
28
|
+
depend_on_parameter_values: list[Any],
|
|
29
|
+
context: PluginContext,
|
|
30
|
+
) -> list[Autocompletion]:
|
|
31
|
+
"""Autocomplete for package_id"""
|
|
32
|
+
entered_package_string = "".join(query_terms)
|
|
33
|
+
|
|
34
|
+
cmem_client = Client.from_context(context=context)
|
|
35
|
+
cmem_client.marketplace.marketplace_url = depend_on_parameter_values[0]
|
|
36
|
+
marketplace_packages = cmem_client.marketplace.get_available_packages()
|
|
37
|
+
|
|
38
|
+
result = [
|
|
39
|
+
Autocompletion(value=package.id, label=f"{package.id} ({package.name})")
|
|
40
|
+
for package in marketplace_packages
|
|
41
|
+
if entered_package_string in package.id
|
|
42
|
+
]
|
|
43
|
+
result.sort(key=lambda x: x.label)
|
|
44
|
+
return result
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class CMEMPackageParameterType(StringParameterType):
|
|
48
|
+
"""Package parameter for plugin autocompletion of packages from the CMEM instance"""
|
|
49
|
+
|
|
50
|
+
def __init__(
|
|
51
|
+
self,
|
|
52
|
+
url_expand: str,
|
|
53
|
+
display_name: str,
|
|
54
|
+
) -> None:
|
|
55
|
+
self.url_expand = url_expand
|
|
56
|
+
self.display_name = display_name
|
|
57
|
+
|
|
58
|
+
allow_only_autocompleted_values = False
|
|
59
|
+
|
|
60
|
+
def autocomplete(
|
|
61
|
+
self,
|
|
62
|
+
query_terms: list[str],
|
|
63
|
+
depend_on_parameter_values: list[Any],
|
|
64
|
+
context: PluginContext,
|
|
65
|
+
) -> list[Autocompletion]:
|
|
66
|
+
"""Autocomplete for package_id"""
|
|
67
|
+
_ = depend_on_parameter_values
|
|
68
|
+
|
|
69
|
+
entered_package_string = "".join(query_terms)
|
|
70
|
+
|
|
71
|
+
cmem_client = Client.from_context(context=context)
|
|
72
|
+
|
|
73
|
+
result = [
|
|
74
|
+
Autocompletion(
|
|
75
|
+
value=package.get_id(),
|
|
76
|
+
label=f"{package.get_id()} ({package.package_version.manifest.metadata.name})",
|
|
77
|
+
)
|
|
78
|
+
for package in cmem_client.marketplace_packages.values()
|
|
79
|
+
if entered_package_string in package.get_id()
|
|
80
|
+
]
|
|
81
|
+
result.sort(key=lambda x: x.label)
|
|
82
|
+
return result
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Publish Marketplace packages to a marketplace server"""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Sequence
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from tempfile import NamedTemporaryFile
|
|
6
|
+
|
|
7
|
+
from cmem_client.eccenca_marketplace_client.package_version import PackageVersion
|
|
8
|
+
from cmem_client.models.credentials import PasswordCredentials
|
|
9
|
+
from cmem_plugin_base.dataintegration.client import get_client
|
|
10
|
+
from cmem_plugin_base.dataintegration.context import ExecutionContext, ExecutionReport
|
|
11
|
+
from cmem_plugin_base.dataintegration.description import Icon, Plugin, PluginParameter
|
|
12
|
+
from cmem_plugin_base.dataintegration.entity import Entities
|
|
13
|
+
from cmem_plugin_base.dataintegration.parameter.password import Password, PasswordParameterType
|
|
14
|
+
from cmem_plugin_base.dataintegration.plugins import WorkflowPlugin
|
|
15
|
+
from cmem_plugin_base.dataintegration.ports import FixedNumberOfInputs, FixedSchemaPort
|
|
16
|
+
from cmem_plugin_base.dataintegration.typed_entities.file import FileEntitySchema
|
|
17
|
+
from pydantic import SecretStr
|
|
18
|
+
|
|
19
|
+
DEFAULT_MARKETPLACE_URL = "https://eccenca.market"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@Plugin(
|
|
23
|
+
label="Publish Packages",
|
|
24
|
+
plugin_id="cmem_plugin_packages-PublishPackages",
|
|
25
|
+
description="Publish CPA packages to a marketplace server.",
|
|
26
|
+
documentation="""
|
|
27
|
+
Publish a CPA package archive to a marketplace server.
|
|
28
|
+
|
|
29
|
+
The input port expects CPA package archives (*.cpa), e.g. as produced by the
|
|
30
|
+
Build Packages task.
|
|
31
|
+
""",
|
|
32
|
+
icon=Icon(file_name="icons/marketplace-publish.svg", package=__package__),
|
|
33
|
+
actions=[],
|
|
34
|
+
parameters=[
|
|
35
|
+
PluginParameter(
|
|
36
|
+
name="marketplace_url",
|
|
37
|
+
label="Marketplace URL",
|
|
38
|
+
description="The URL of the marketplace server to publish packages to.",
|
|
39
|
+
default_value=DEFAULT_MARKETPLACE_URL,
|
|
40
|
+
),
|
|
41
|
+
PluginParameter(
|
|
42
|
+
name="username",
|
|
43
|
+
label="Keycloak username",
|
|
44
|
+
description="The username to authenticate with the Keycloak server.",
|
|
45
|
+
),
|
|
46
|
+
PluginParameter(
|
|
47
|
+
name="password",
|
|
48
|
+
label="Keycloak password",
|
|
49
|
+
description="The password to authenticate with the Keycloak server.",
|
|
50
|
+
param_type=PasswordParameterType(),
|
|
51
|
+
),
|
|
52
|
+
],
|
|
53
|
+
)
|
|
54
|
+
class PublishMarketplacePackages(WorkflowPlugin):
|
|
55
|
+
"""Publish Marketplace packages to a marketplace server"""
|
|
56
|
+
|
|
57
|
+
def __init__(
|
|
58
|
+
self,
|
|
59
|
+
marketplace_url: str = DEFAULT_MARKETPLACE_URL,
|
|
60
|
+
username: str = "",
|
|
61
|
+
password: Password | str = "",
|
|
62
|
+
):
|
|
63
|
+
self.marketplace_url = marketplace_url
|
|
64
|
+
self.username = username
|
|
65
|
+
self.password = password if isinstance(password, str) else password.decrypt()
|
|
66
|
+
self.credentials = PasswordCredentials(
|
|
67
|
+
username=self.username, password=SecretStr(self.password)
|
|
68
|
+
)
|
|
69
|
+
self.input_ports = FixedNumberOfInputs([FixedSchemaPort(schema=FileEntitySchema())])
|
|
70
|
+
self.output_port = None
|
|
71
|
+
|
|
72
|
+
def execute(self, inputs: Sequence[Entities], context: ExecutionContext) -> None:
|
|
73
|
+
"""Execute the workflow"""
|
|
74
|
+
cmem_client = get_client(context=context)
|
|
75
|
+
cmem_client.marketplace.marketplace_url = self.marketplace_url
|
|
76
|
+
cmem_client.marketplace.credentials = self.credentials
|
|
77
|
+
|
|
78
|
+
file_schema = FileEntitySchema()
|
|
79
|
+
uploaded_count = 0
|
|
80
|
+
error: str | None = None
|
|
81
|
+
|
|
82
|
+
for entity in inputs[0].entities:
|
|
83
|
+
cpa_file = file_schema.from_entity(entity)
|
|
84
|
+
|
|
85
|
+
with NamedTemporaryFile(suffix=".cpa", delete=False) as tmp:
|
|
86
|
+
tmp_path = Path(tmp.name)
|
|
87
|
+
tmp.write(cpa_file.read_bytes(context=context))
|
|
88
|
+
|
|
89
|
+
package_id = "<unknown>"
|
|
90
|
+
try:
|
|
91
|
+
package_version = PackageVersion.from_archive(tmp_path)
|
|
92
|
+
package_id = package_version.manifest.package_id
|
|
93
|
+
|
|
94
|
+
context.report.update(
|
|
95
|
+
ExecutionReport(
|
|
96
|
+
entity_count=uploaded_count,
|
|
97
|
+
operation="Upload",
|
|
98
|
+
operation_desc=f"uploading: {package_id}",
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
cmem_client.marketplace.upload_package(package_id=package_id, path=tmp_path)
|
|
102
|
+
uploaded_count += 1
|
|
103
|
+
|
|
104
|
+
except Exception as e: # noqa: BLE001
|
|
105
|
+
error = f"Upload failed for {package_id}: {e}"
|
|
106
|
+
|
|
107
|
+
finally:
|
|
108
|
+
tmp_path.unlink(missing_ok=True)
|
|
109
|
+
|
|
110
|
+
context.report.update(
|
|
111
|
+
ExecutionReport(
|
|
112
|
+
entity_count=uploaded_count,
|
|
113
|
+
operation="Finish",
|
|
114
|
+
operation_desc=f"package{'s' if uploaded_count > 1 else ''} uploaded",
|
|
115
|
+
error=error,
|
|
116
|
+
)
|
|
117
|
+
)
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"""Marketplace Plugin for uninstalling packages"""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Sequence
|
|
4
|
+
|
|
5
|
+
from cmem_client.client import Client
|
|
6
|
+
from cmem_client.eccenca_marketplace_client.models.dependencies import MarketplacePackageDependency
|
|
7
|
+
from cmem_client.models.package import Package
|
|
8
|
+
from cmem_plugin_base.dataintegration.context import (
|
|
9
|
+
ExecutionContext,
|
|
10
|
+
ExecutionReport,
|
|
11
|
+
PluginContext,
|
|
12
|
+
)
|
|
13
|
+
from cmem_plugin_base.dataintegration.description import Icon, Plugin, PluginAction, PluginParameter
|
|
14
|
+
from cmem_plugin_base.dataintegration.entity import Entities, EntityPath, EntitySchema
|
|
15
|
+
from cmem_plugin_base.dataintegration.plugins import WorkflowPlugin
|
|
16
|
+
from cmem_plugin_base.dataintegration.ports import FixedNumberOfInputs, FixedSchemaPort
|
|
17
|
+
from cmem_plugin_base.dataintegration.types import BoolParameterType
|
|
18
|
+
|
|
19
|
+
from cmem_plugin_packages.package_parameter import (
|
|
20
|
+
CMEMPackageParameterType,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
UNINSTALL_PACKAGE_SCHEMA = EntitySchema(
|
|
24
|
+
type_uri="",
|
|
25
|
+
paths=[EntityPath("package_id")],
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@Plugin(
|
|
30
|
+
label="Uninstall Packages",
|
|
31
|
+
plugin_id="cmem_plugin_packages-UninstallPackages",
|
|
32
|
+
description="""Uninstall installed packages.""",
|
|
33
|
+
documentation="""Uninstalls installed packages and their dependencies from Corporate Memory.
|
|
34
|
+
|
|
35
|
+
This task supports three package uninstallation modes (mutually exclusive):
|
|
36
|
+
|
|
37
|
+
1. **Package ID** (default): Uninstalls a single package selected via the *Package ID* parameter.
|
|
38
|
+
2. **Package list from input port**: Uninstall multiple packages.
|
|
39
|
+
3. **Uninstall all packages**: Removes every installed package.
|
|
40
|
+
|
|
41
|
+
Use **Preview dependencies** to inspect which dependencies will be removed as well
|
|
42
|
+
(**Package ID** mode only).""",
|
|
43
|
+
icon=Icon(file_name="icons/marketplace-uninstall.svg", package=__package__),
|
|
44
|
+
actions=[
|
|
45
|
+
PluginAction(
|
|
46
|
+
name="preview_dependencies",
|
|
47
|
+
label="Preview dependencies",
|
|
48
|
+
description="""Preview the marketplace package dependencies.""",
|
|
49
|
+
)
|
|
50
|
+
],
|
|
51
|
+
parameters=[
|
|
52
|
+
PluginParameter(
|
|
53
|
+
name="package_id",
|
|
54
|
+
label="Package ID",
|
|
55
|
+
description="The identifier of the installed package.",
|
|
56
|
+
param_type=CMEMPackageParameterType("", ""),
|
|
57
|
+
default_value="",
|
|
58
|
+
),
|
|
59
|
+
PluginParameter(
|
|
60
|
+
name="ignore_not_installed_packages",
|
|
61
|
+
label="Ignore not installed packages",
|
|
62
|
+
description="If enabled, the task will report a warning instead of raising an "
|
|
63
|
+
"error on packages which are not installed.",
|
|
64
|
+
param_type=BoolParameterType(),
|
|
65
|
+
default_value=False,
|
|
66
|
+
),
|
|
67
|
+
PluginParameter(
|
|
68
|
+
name="uninstall_list_of_packages",
|
|
69
|
+
label="Uninstall listed packages from input port",
|
|
70
|
+
description="""If enabled, the task will provide an input port to uninstall a
|
|
71
|
+
package list delivered from a previous task in the workflow.
|
|
72
|
+
|
|
73
|
+
The requested input schema path is `package_id` (mandatory).
|
|
74
|
+
The configured package ID will be ignored.""",
|
|
75
|
+
param_type=BoolParameterType(),
|
|
76
|
+
default_value=False,
|
|
77
|
+
),
|
|
78
|
+
PluginParameter(
|
|
79
|
+
name="uninstall_all_packages",
|
|
80
|
+
label="Uninstall all packages",
|
|
81
|
+
description="""If enabled, all installed packages will be uninstalled.
|
|
82
|
+
|
|
83
|
+
The configured package ID will be ignored.""",
|
|
84
|
+
param_type=BoolParameterType(),
|
|
85
|
+
default_value=False,
|
|
86
|
+
),
|
|
87
|
+
],
|
|
88
|
+
)
|
|
89
|
+
class UninstallMarketplacePackages(WorkflowPlugin):
|
|
90
|
+
"""Uninstall Marketplace packages from this CMEM instance"""
|
|
91
|
+
|
|
92
|
+
def __init__(
|
|
93
|
+
self,
|
|
94
|
+
package_id: str,
|
|
95
|
+
ignore_not_installed_packages: bool,
|
|
96
|
+
uninstall_list_of_packages: bool,
|
|
97
|
+
uninstall_all_packages: bool,
|
|
98
|
+
):
|
|
99
|
+
if uninstall_list_of_packages and uninstall_all_packages:
|
|
100
|
+
raise ValueError(
|
|
101
|
+
"Cannot enable uninstall of all packages and uninstalling from a list. "
|
|
102
|
+
"Choose one option"
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
if not uninstall_all_packages and not uninstall_list_of_packages and package_id == "":
|
|
106
|
+
raise ValueError("Please provide a package ID.")
|
|
107
|
+
|
|
108
|
+
if uninstall_all_packages and package_id != "":
|
|
109
|
+
raise ValueError(
|
|
110
|
+
"Cannot enable uninstall of all packages and uninstalling from a "
|
|
111
|
+
"specified package ID. "
|
|
112
|
+
"Please choose one option"
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
if uninstall_list_of_packages and package_id != "":
|
|
116
|
+
raise ValueError(
|
|
117
|
+
"Cannot enable uninstalling of a list of packages and uninstalling from a "
|
|
118
|
+
"specified package ID. "
|
|
119
|
+
"Please choose one option"
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
self.package_id = package_id
|
|
123
|
+
self.ignore_not_installed_packages = ignore_not_installed_packages
|
|
124
|
+
self.uninstall_all_packages = uninstall_all_packages
|
|
125
|
+
self.uninstall_list_of_packages = uninstall_list_of_packages
|
|
126
|
+
self.input_ports = (
|
|
127
|
+
FixedNumberOfInputs([])
|
|
128
|
+
if not self.uninstall_list_of_packages
|
|
129
|
+
else FixedNumberOfInputs([FixedSchemaPort(schema=UNINSTALL_PACKAGE_SCHEMA)])
|
|
130
|
+
)
|
|
131
|
+
self.output_port = None
|
|
132
|
+
|
|
133
|
+
def execute(self, inputs: Sequence[Entities], context: ExecutionContext) -> None:
|
|
134
|
+
"""Execute the workflow"""
|
|
135
|
+
cmem_client = Client.from_context(context=context)
|
|
136
|
+
|
|
137
|
+
packages = list(cmem_client.marketplace_packages)
|
|
138
|
+
|
|
139
|
+
if inputs:
|
|
140
|
+
self._uninstall_from_list(cmem_client, context, inputs)
|
|
141
|
+
|
|
142
|
+
elif self.uninstall_all_packages:
|
|
143
|
+
self._uninstall_all_packages(cmem_client, context, packages)
|
|
144
|
+
|
|
145
|
+
else:
|
|
146
|
+
self._uninstall_from_parameter(cmem_client, context, packages)
|
|
147
|
+
|
|
148
|
+
def _uninstall_from_parameter(
|
|
149
|
+
self, cmem_client: Client, context: ExecutionContext, packages: list[Package]
|
|
150
|
+
) -> None:
|
|
151
|
+
if self.ignore_not_installed_packages and self.package_id not in packages:
|
|
152
|
+
context.report.update(
|
|
153
|
+
ExecutionReport(
|
|
154
|
+
entity_count=1,
|
|
155
|
+
operation="Skipping",
|
|
156
|
+
operation_desc=f"package skipped because it is not "
|
|
157
|
+
f"installed: {self.package_id}",
|
|
158
|
+
)
|
|
159
|
+
)
|
|
160
|
+
return
|
|
161
|
+
|
|
162
|
+
context.report.update(
|
|
163
|
+
ExecutionReport(
|
|
164
|
+
entity_count=1,
|
|
165
|
+
operation="Uninstalling",
|
|
166
|
+
operation_desc=f"package uninstalling: {self.package_id}",
|
|
167
|
+
)
|
|
168
|
+
)
|
|
169
|
+
cmem_client.marketplace_packages.delete_item(
|
|
170
|
+
key=self.package_id, skip_if_missing=self.ignore_not_installed_packages
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
context.report.update(
|
|
174
|
+
ExecutionReport(
|
|
175
|
+
entity_count=1,
|
|
176
|
+
operation="Uninstall",
|
|
177
|
+
operation_desc=f"package uninstalled: {self.package_id}",
|
|
178
|
+
)
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
def _uninstall_all_packages(
|
|
182
|
+
self, cmem_client: Client, context: ExecutionContext, packages: list[Package]
|
|
183
|
+
) -> None:
|
|
184
|
+
entity_counter = 0
|
|
185
|
+
|
|
186
|
+
if len(packages) == 0:
|
|
187
|
+
if self.ignore_not_installed_packages:
|
|
188
|
+
context.report.update(
|
|
189
|
+
ExecutionReport(
|
|
190
|
+
warnings=["No packages to uninstall."],
|
|
191
|
+
operation="Skipped",
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
return
|
|
195
|
+
raise ValueError("No packages to uninstall")
|
|
196
|
+
|
|
197
|
+
for package in packages:
|
|
198
|
+
entity_counter += 1
|
|
199
|
+
context.report.update(
|
|
200
|
+
ExecutionReport(
|
|
201
|
+
entity_count=entity_counter,
|
|
202
|
+
operation="Uninstalling",
|
|
203
|
+
operation_desc=f"package{'s' if entity_counter > 1 else ''} "
|
|
204
|
+
f"uninstalling: {package}",
|
|
205
|
+
)
|
|
206
|
+
)
|
|
207
|
+
cmem_client.marketplace_packages.delete_item(
|
|
208
|
+
package, skip_if_missing=self.ignore_not_installed_packages
|
|
209
|
+
)
|
|
210
|
+
context.report.update(
|
|
211
|
+
ExecutionReport(
|
|
212
|
+
entity_count=entity_counter,
|
|
213
|
+
operation="Uninstall",
|
|
214
|
+
operation_desc=f"package{'s' if entity_counter > 1 else ''} uninstalled",
|
|
215
|
+
)
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
def _uninstall_from_list(
|
|
219
|
+
self, cmem_client: Client, context: ExecutionContext, inputs: Sequence[Entities]
|
|
220
|
+
) -> None:
|
|
221
|
+
entities = inputs[0].entities
|
|
222
|
+
entity_counter = 0
|
|
223
|
+
warnings = []
|
|
224
|
+
|
|
225
|
+
for entity in entities:
|
|
226
|
+
entity_values = entity.values
|
|
227
|
+
package_id = entity_values[0][0]
|
|
228
|
+
entity_counter += 1
|
|
229
|
+
context.report.update(
|
|
230
|
+
ExecutionReport(
|
|
231
|
+
entity_count=entity_counter,
|
|
232
|
+
operation="Uninstalling",
|
|
233
|
+
operation_desc=f"package{'s' if entity_counter > 1 else ''} "
|
|
234
|
+
f"uninstalling: {package_id}",
|
|
235
|
+
)
|
|
236
|
+
)
|
|
237
|
+
if package_id not in cmem_client.marketplace_packages:
|
|
238
|
+
if self.ignore_not_installed_packages:
|
|
239
|
+
warnings.append(f"Skipped package {package_id} because it is not installed.")
|
|
240
|
+
else:
|
|
241
|
+
raise RuntimeError(
|
|
242
|
+
f"Cannot uninstall package {package_id} because it is not installed."
|
|
243
|
+
)
|
|
244
|
+
cmem_client.marketplace_packages.delete_item(
|
|
245
|
+
package_id, skip_if_missing=self.ignore_not_installed_packages
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
if warnings:
|
|
249
|
+
context.report.update(
|
|
250
|
+
ExecutionReport(
|
|
251
|
+
entity_count=entity_counter,
|
|
252
|
+
operation="Uninstall",
|
|
253
|
+
warnings=warnings,
|
|
254
|
+
operation_desc=f"package{'s' if entity_counter > 1 else ''} uninstalled",
|
|
255
|
+
)
|
|
256
|
+
)
|
|
257
|
+
else:
|
|
258
|
+
context.report.update(
|
|
259
|
+
ExecutionReport(
|
|
260
|
+
entity_count=entity_counter,
|
|
261
|
+
operation="Uninstall",
|
|
262
|
+
operation_desc=f"package{'s' if entity_counter > 1 else ''} uninstalled",
|
|
263
|
+
)
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
def preview_dependencies(self, context: PluginContext) -> str:
|
|
267
|
+
"""Preview the marketplace package dependencies"""
|
|
268
|
+
preview = ""
|
|
269
|
+
|
|
270
|
+
if self.package_id == "":
|
|
271
|
+
return "Please select a package ID first."
|
|
272
|
+
|
|
273
|
+
cmem_client = Client.from_context(context=context)
|
|
274
|
+
package = cmem_client.marketplace_packages[self.package_id]
|
|
275
|
+
package_dependencies = package.package_version.manifest.dependencies
|
|
276
|
+
|
|
277
|
+
if not package_dependencies:
|
|
278
|
+
return "No dependencies found."
|
|
279
|
+
|
|
280
|
+
preview += "| Dependency | Type |\n"
|
|
281
|
+
preview += "|------------|------|\n"
|
|
282
|
+
for dep_ref in package_dependencies:
|
|
283
|
+
dependency = (
|
|
284
|
+
cmem_client.marketplace_packages[dep_ref.package_id]
|
|
285
|
+
if isinstance(dep_ref, MarketplacePackageDependency)
|
|
286
|
+
else cmem_client.python_packages[dep_ref.pypi_id]
|
|
287
|
+
)
|
|
288
|
+
if isinstance(dependency, Package):
|
|
289
|
+
dep_name = dependency.package_version.manifest.package_id
|
|
290
|
+
dep_type = "marketplace-package"
|
|
291
|
+
else:
|
|
292
|
+
dep_name = dependency.name
|
|
293
|
+
dep_type = "python-package"
|
|
294
|
+
preview += f"| {dep_name} | {dep_type} |\n"
|
|
295
|
+
|
|
296
|
+
return preview
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cmem-plugin-packages
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Install and uninstall eccenca marketplace packages!
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: eccenca Corporate Memory,plugin
|
|
8
|
+
Author: eccenca GmbH
|
|
9
|
+
Author-email: cmempy-developer@eccenca.com
|
|
10
|
+
Requires-Python: >=3.13,<4.0
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Plugins
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Dist: cmem-client (>=0.16.1)
|
|
18
|
+
Requires-Dist: cmem-plugin-base (>=4.19.0,<5.0.0)
|
|
19
|
+
Requires-Dist: pydantic (>=2.12.5,<3.0.0)
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# cmem-plugin-packages
|
|
23
|
+
|
|
24
|
+
Install and uninstall eccenca marketplace packages!
|
|
25
|
+
|
|
26
|
+
[![eccenca Corporate Memory][cmem-shield]][cmem-link]
|
|
27
|
+
|
|
28
|
+
This is a plugin for [eccenca](https://eccenca.com) [Corporate Memory](https://documentation.eccenca.com). You can install it with the [cmemc](https://eccenca.com/go/cmemc) command line client like this:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
cmemc admin workspace python install cmem-plugin-packages
|
|
32
|
+
```
|
|
33
|
+
[](https://pypi.org/project/cmem-plugin-packages) [](https://pypi.org/project/cmem-plugin-packages)
|
|
34
|
+
[![poetry][poetry-shield]][poetry-link] [![ruff][ruff-shield]][ruff-link] [![mypy][mypy-shield]][mypy-link] [![copier][copier-shield]][copier]
|
|
35
|
+
|
|
36
|
+
[cmem-link]: https://documentation.eccenca.com
|
|
37
|
+
[cmem-shield]: https://img.shields.io/endpoint?url=https://dev.documentation.eccenca.com/badge.json
|
|
38
|
+
[poetry-link]: https://python-poetry.org/
|
|
39
|
+
[poetry-shield]: https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json
|
|
40
|
+
[ruff-link]: https://docs.astral.sh/ruff/
|
|
41
|
+
[ruff-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&label=Code%20Style
|
|
42
|
+
[mypy-link]: https://mypy-lang.org/
|
|
43
|
+
[mypy-shield]: https://www.mypy-lang.org/static/mypy_badge.svg
|
|
44
|
+
[copier]: https://copier.readthedocs.io/
|
|
45
|
+
[copier-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-purple.json
|
|
46
|
+
|
|
47
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
cmem_plugin_packages/__init__.py,sha256=WnHH0x3kGJQjIxXX7llJOpEj_sowOpCnu0Uq_WpEx2k,27
|
|
2
|
+
cmem_plugin_packages/build_packages.py,sha256=zyiMitmr6a6kDxKR5vkkwLYLMnvV5K2eiSHonGP6qik,5684
|
|
3
|
+
cmem_plugin_packages/icons/marketplace-build.svg,sha256=Vtx53JSbmDVmy8iHZVvRiIhdJDqw4pyTAyzuT8xHXJo,526
|
|
4
|
+
cmem_plugin_packages/icons/marketplace-install.svg,sha256=coIiEBBWpd4jGAEaI6eTsjcn_rRrgF036FmjMkL7sYI,501
|
|
5
|
+
cmem_plugin_packages/icons/marketplace-publish.svg,sha256=o0PVcgKxituyt8CErZ1hryyVgRZddukaz1SYcA9U_v4,976
|
|
6
|
+
cmem_plugin_packages/icons/marketplace-uninstall.svg,sha256=h2U-KCFnOgVUS-2rnDeov48AWj8r8uFrLl8E3Y12p58,471
|
|
7
|
+
cmem_plugin_packages/install_packages.py,sha256=bCUZv-_00ozLQkCISMRonN8MIFrGvHtSngAWaKQ270M,14104
|
|
8
|
+
cmem_plugin_packages/package_parameter.py,sha256=JGDdzdQV8QrhOS0Q9gbjv7yUIBzoL0Bb0XnUk34RDFo,2674
|
|
9
|
+
cmem_plugin_packages/publish_packages.py,sha256=IrrkWuwWp3FCK11WNJF65uGelKC944WV5jV6dylMzlc,4605
|
|
10
|
+
cmem_plugin_packages/uninstall_packages.py,sha256=mor9B-T7F0XbW-HE583s_EehXV2Jw6ZCr2vgs_4ia5o,11349
|
|
11
|
+
cmem_plugin_packages-0.9.0.dist-info/METADATA,sha256=XTxwofiMXdqmw5-GpnzXB-HJ84JCJbbrHkYmnvtyYuk,2319
|
|
12
|
+
cmem_plugin_packages-0.9.0.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
|
|
13
|
+
cmem_plugin_packages-0.9.0.dist-info/licenses/LICENSE,sha256=5t6lcWcFU3TBO5wwq9PYNbgzfVfFUuL-80v5BTGuuMQ,11334
|
|
14
|
+
cmem_plugin_packages-0.9.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2021 CMEM
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|