shellsmith 0.4.0__tar.gz → 0.5.0__tar.gz

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.
Files changed (38) hide show
  1. {shellsmith-0.4.0 → shellsmith-0.5.0}/PKG-INFO +45 -38
  2. {shellsmith-0.4.0 → shellsmith-0.5.0}/README.md +38 -33
  3. {shellsmith-0.4.0 → shellsmith-0.5.0}/pyproject.toml +7 -9
  4. shellsmith-0.4.0/src/shellsmith/cli/__init__.py +0 -0
  5. shellsmith-0.4.0/src/shellsmith/cli/app.py +0 -44
  6. shellsmith-0.4.0/src/shellsmith/cli/args.py +0 -30
  7. shellsmith-0.4.0/src/shellsmith/cli/commands/__init__.py +0 -0
  8. shellsmith-0.4.0/src/shellsmith/cli/commands/decode.py +0 -13
  9. shellsmith-0.4.0/src/shellsmith/cli/commands/encode.py +0 -13
  10. shellsmith-0.4.0/src/shellsmith/cli/commands/groups/__init__.py +0 -0
  11. shellsmith-0.4.0/src/shellsmith/cli/commands/groups/create.py +0 -79
  12. shellsmith-0.4.0/src/shellsmith/cli/commands/groups/delete.py +0 -83
  13. shellsmith-0.4.0/src/shellsmith/cli/commands/groups/get.py +0 -165
  14. shellsmith-0.4.0/src/shellsmith/cli/commands/groups/update.py +0 -111
  15. shellsmith-0.4.0/src/shellsmith/cli/commands/info.py +0 -71
  16. shellsmith-0.4.0/src/shellsmith/cli/commands/nuke.py +0 -66
  17. shellsmith-0.4.0/src/shellsmith/cli/commands/upload.py +0 -32
  18. shellsmith-0.4.0/src/shellsmith/cli/formats.py +0 -13
  19. shellsmith-0.4.0/src/shellsmith/cli/handlers.py +0 -31
  20. shellsmith-0.4.0/src/shellsmith/cli/opts.py +0 -41
  21. shellsmith-0.4.0/src/shellsmith/cli/pretty.py +0 -142
  22. shellsmith-0.4.0/src/shellsmith/cli/resolve.py +0 -30
  23. shellsmith-0.4.0/src/shellsmith/cli/simplify.py +0 -74
  24. shellsmith-0.4.0/src/shellsmith/mcp/__init__.py +0 -5
  25. shellsmith-0.4.0/src/shellsmith/mcp/server.py +0 -613
  26. {shellsmith-0.4.0 → shellsmith-0.5.0}/.gitignore +0 -0
  27. {shellsmith-0.4.0 → shellsmith-0.5.0}/LICENSE +0 -0
  28. {shellsmith-0.4.0 → shellsmith-0.5.0}/src/shellsmith/__init__.py +0 -0
  29. {shellsmith-0.4.0 → shellsmith-0.5.0}/src/shellsmith/__main__.py +0 -0
  30. {shellsmith-0.4.0 → shellsmith-0.5.0}/src/shellsmith/api.py +0 -0
  31. {shellsmith-0.4.0 → shellsmith-0.5.0}/src/shellsmith/clients.py +0 -0
  32. {shellsmith-0.4.0 → shellsmith-0.5.0}/src/shellsmith/config.py +0 -0
  33. {shellsmith-0.4.0 → shellsmith-0.5.0}/src/shellsmith/extract.py +0 -0
  34. {shellsmith-0.4.0 → shellsmith-0.5.0}/src/shellsmith/neo4j.py +0 -0
  35. {shellsmith-0.4.0 → shellsmith-0.5.0}/src/shellsmith/services.py +0 -0
  36. {shellsmith-0.4.0 → shellsmith-0.5.0}/src/shellsmith/types.py +0 -0
  37. {shellsmith-0.4.0 → shellsmith-0.5.0}/src/shellsmith/upload.py +0 -0
  38. {shellsmith-0.4.0 → shellsmith-0.5.0}/src/shellsmith/utils.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shellsmith
3
- Version: 0.4.0
4
- Summary: A Python SDK and CLI for Eclipse BaSyx to manage Asset Administration Shells (AAS)
3
+ Version: 0.5.0
4
+ Summary: A Python SDK for Eclipse BaSyx to manage Asset Administration Shells (AAS)
5
5
  Project-URL: Homepage, https://github.com/SmartFactory-KL/shellsmith
6
6
  Project-URL: Issues, https://github.com/SmartFactory-KL/shellsmith/issues
7
7
  Project-URL: Documentation, https://shellsmith.pages.dev
@@ -28,7 +28,7 @@ License: MIT License
28
28
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
29
  SOFTWARE.
30
30
  License-File: LICENSE
31
- Keywords: aas,asset-administration-shell,basyx,cli,digital-twin,eclipse-basyx,i40,industry40,python,rest-client,typer
31
+ Keywords: aas,asset-administration-shell,basyx,digital-twin,eclipse-basyx,i40,industry40,python,rest-client
32
32
  Classifier: Environment :: Console
33
33
  Classifier: Intended Audience :: Developers
34
34
  Classifier: License :: OSI Approved :: MIT License
@@ -41,15 +41,17 @@ Classifier: Programming Language :: Python :: 3.13
41
41
  Classifier: Topic :: Software Development :: Libraries
42
42
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
43
43
  Requires-Python: >=3.10
44
- Requires-Dist: fastmcp
45
44
  Requires-Dist: httpx
46
45
  Requires-Dist: pydantic-settings
47
46
  Requires-Dist: pyyaml
48
- Requires-Dist: typer
47
+ Provides-Extra: cli
48
+ Requires-Dist: aas-cli; extra == 'cli'
49
49
  Provides-Extra: docs
50
50
  Requires-Dist: mkdocs; extra == 'docs'
51
51
  Requires-Dist: mkdocs-material; extra == 'docs'
52
52
  Requires-Dist: termynal; extra == 'docs'
53
+ Provides-Extra: mcp
54
+ Requires-Dist: aas-mcp; extra == 'mcp'
53
55
  Provides-Extra: neo4j
54
56
  Requires-Dist: neo4j; extra == 'neo4j'
55
57
  Provides-Extra: test
@@ -64,7 +66,7 @@ Requires-Dist: types-requests; extra == 'test'
64
66
  Description-Content-Type: text/markdown
65
67
 
66
68
  <div align="center">
67
- <img src="https://raw.githubusercontent.com/SmartFactory-KL/shellsmith/main/docs/images/logo-purple-500.png" alt="shellsmith">
69
+ <img src="https://raw.githubusercontent.com/SmartFactory-KL/shellsmith/main/docs/images/banner-purple-500.png" alt="shellsmith">
68
70
  </div>
69
71
 
70
72
  <div align="center">
@@ -78,26 +80,45 @@ Description-Content-Type: text/markdown
78
80
  <b>Documentation</b>: <a href="https://shellsmith.pages.dev/" target="_blank">https://shellsmith.pages.dev</a>
79
81
  </p>
80
82
 
81
- **Shellsmith** is a Python SDK and CLI for managing [Asset Administration Shells (AAS)](https://industrialdigitaltwin.org/en/content-hub/aasspecifications), Submodels, and Submodel Elements via the [Eclipse BaSyx](https://www.eclipse.org/basyx/) REST API.
82
-
83
- It provides full client-side access to AAS resources with a clean Python interface and a powerful `typer`-based CLI — ideal for scripting, automation, and digital twin integration workflows.
83
+ **Shellsmith** is a Python SDK for managing [Asset Administration Shells (AAS)](https://industrialdigitaltwin.org/en/content-hub/aasspecifications) via the [Eclipse BaSyx](https://www.eclipse.org/basyx/) REST API.
84
84
 
85
- ### Features
85
+ ## Installation
86
86
 
87
- - 🐍 **Python SDK** for full CRUD access to Shells, Submodels, and Submodel Elements
88
- - ⚡ **CLI tool** powered by [Typer](https://typer.tiangolo.com/) for fast scripting and automation
89
- - ⚙️ Simple `.env`-based configuration for flexible environment switching
90
- - 🔁 Seamless integration with the [Eclipse BaSyx](https://www.eclipse.org/basyx/) Environment REST API
87
+ ```bash
88
+ pip install shellsmith
89
+ ```
91
90
 
92
- ## 🚀 Installation
91
+ For CLI and MCP server support, install with optional dependencies:
93
92
 
94
93
  ```bash
95
- pip install shellsmith
94
+ pip install shellsmith[cli,mcp]
96
95
  ```
97
96
 
98
97
  **Requires**: Python 3.10+
99
98
 
100
- ## 🧠 CLI Usage
99
+ ## Python API Usage
100
+
101
+ You can also use `shellsmith` as a Python client library to interact with the BaSyx Environment REST API.
102
+
103
+ ```python
104
+ import shellsmith
105
+
106
+ # Fetch all AAS Shells
107
+ shells = shellsmith.get_shells()
108
+
109
+ # Fetch a specific Submodel
110
+ submodel = shellsmith.get_submodel("https://example.com/submodels/my-submodel")
111
+
112
+ # Read and update a Submodel Element's value
113
+ value = shellsmith.get_submodel_element_value(submodel["id"], "temperature")
114
+ shellsmith.patch_submodel_element_value(submodel["id"], "temperature", "42.0")
115
+ ```
116
+
117
+ > ℹ️ `shell_id` and `submodel_id` are automatically base64-encoded unless you pass `encode=False`.
118
+
119
+ ➡️ Full Python API reference: [shellsmith.pages.dev/api](https://shellsmith.pages.dev/api)
120
+
121
+ ## CLI Usage
101
122
 
102
123
  Shellsmith provides a powerful command-line interface:
103
124
 
@@ -121,29 +142,15 @@ aas --help
121
142
 
122
143
  ➡️ Full CLI reference: [shellsmith.pages.dev/cli](https://shellsmith.pages.dev/cli)
123
144
 
124
- ## 🐍 Python API Usage
145
+ ## MCP Integration
125
146
 
126
- You can also use `shellsmith` as a Python client library to interact with the BaSyx Environment REST API.
147
+ Shellsmith provides a Model Context Protocol (MCP) server that enables AI assistants to interact with Asset Administration Shells. The server exposes 25+ tools for comprehensive AAS management through a standardized interface.
127
148
 
128
- ```python
129
- import shellsmith
149
+ Configure with Claude Desktop or other MCP clients to get AI-powered AAS operations.
130
150
 
131
- # Fetch all AAS Shells
132
- shells = shellsmith.get_shells()
133
-
134
- # Fetch a specific Submodel
135
- submodel = shellsmith.get_submodel("https://example.com/submodels/my-submodel")
136
-
137
- # Read and update a Submodel Element's value
138
- value = shellsmith.get_submodel_element_value(submodel["id"], "temperature")
139
- shellsmith.patch_submodel_element_value(submodel["id"], "temperature", "42.0")
140
- ```
141
-
142
- > ℹ️ `shell_id` and `submodel_id` are automatically base64-encoded unless you pass `encode=False`.
143
-
144
- ➡️ Full Python API reference: [shellsmith.pages.dev/api](https://shellsmith.pages.dev/api)
151
+ ➡️ Full MCP reference: [shellsmith.pages.dev/mcp](https://shellsmith.pages.dev/mcp)
145
152
 
146
- ## 🔧 Configuration
153
+ ## Configuration
147
154
 
148
155
  The default AAS environment host is:
149
156
 
@@ -173,9 +180,9 @@ You can override it in several ways:
173
180
  shellsmith.get_shells(host="https://your-host:1234")
174
181
  ```
175
182
 
176
- > 💡 The `--host` CLI flag and `host=` Python argument **take precedence** over environment variables and `.env`.
183
+ > ℹ️ The `--host` CLI flag and `host=` Python argument **take precedence** over environment variables and `.env`.
177
184
 
178
- ## 🤝 Contributing
185
+ ## Contributing
179
186
 
180
187
  We welcome contributions!
181
188
 
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="https://raw.githubusercontent.com/SmartFactory-KL/shellsmith/main/docs/images/logo-purple-500.png" alt="shellsmith">
2
+ <img src="https://raw.githubusercontent.com/SmartFactory-KL/shellsmith/main/docs/images/banner-purple-500.png" alt="shellsmith">
3
3
  </div>
4
4
 
5
5
  <div align="center">
@@ -13,26 +13,45 @@
13
13
  <b>Documentation</b>: <a href="https://shellsmith.pages.dev/" target="_blank">https://shellsmith.pages.dev</a>
14
14
  </p>
15
15
 
16
- **Shellsmith** is a Python SDK and CLI for managing [Asset Administration Shells (AAS)](https://industrialdigitaltwin.org/en/content-hub/aasspecifications), Submodels, and Submodel Elements via the [Eclipse BaSyx](https://www.eclipse.org/basyx/) REST API.
17
-
18
- It provides full client-side access to AAS resources with a clean Python interface and a powerful `typer`-based CLI — ideal for scripting, automation, and digital twin integration workflows.
16
+ **Shellsmith** is a Python SDK for managing [Asset Administration Shells (AAS)](https://industrialdigitaltwin.org/en/content-hub/aasspecifications) via the [Eclipse BaSyx](https://www.eclipse.org/basyx/) REST API.
19
17
 
20
- ### Features
18
+ ## Installation
21
19
 
22
- - 🐍 **Python SDK** for full CRUD access to Shells, Submodels, and Submodel Elements
23
- - ⚡ **CLI tool** powered by [Typer](https://typer.tiangolo.com/) for fast scripting and automation
24
- - ⚙️ Simple `.env`-based configuration for flexible environment switching
25
- - 🔁 Seamless integration with the [Eclipse BaSyx](https://www.eclipse.org/basyx/) Environment REST API
20
+ ```bash
21
+ pip install shellsmith
22
+ ```
26
23
 
27
- ## 🚀 Installation
24
+ For CLI and MCP server support, install with optional dependencies:
28
25
 
29
26
  ```bash
30
- pip install shellsmith
27
+ pip install shellsmith[cli,mcp]
31
28
  ```
32
29
 
33
30
  **Requires**: Python 3.10+
34
31
 
35
- ## 🧠 CLI Usage
32
+ ## Python API Usage
33
+
34
+ You can also use `shellsmith` as a Python client library to interact with the BaSyx Environment REST API.
35
+
36
+ ```python
37
+ import shellsmith
38
+
39
+ # Fetch all AAS Shells
40
+ shells = shellsmith.get_shells()
41
+
42
+ # Fetch a specific Submodel
43
+ submodel = shellsmith.get_submodel("https://example.com/submodels/my-submodel")
44
+
45
+ # Read and update a Submodel Element's value
46
+ value = shellsmith.get_submodel_element_value(submodel["id"], "temperature")
47
+ shellsmith.patch_submodel_element_value(submodel["id"], "temperature", "42.0")
48
+ ```
49
+
50
+ > ℹ️ `shell_id` and `submodel_id` are automatically base64-encoded unless you pass `encode=False`.
51
+
52
+ ➡️ Full Python API reference: [shellsmith.pages.dev/api](https://shellsmith.pages.dev/api)
53
+
54
+ ## CLI Usage
36
55
 
37
56
  Shellsmith provides a powerful command-line interface:
38
57
 
@@ -56,29 +75,15 @@ aas --help
56
75
 
57
76
  ➡️ Full CLI reference: [shellsmith.pages.dev/cli](https://shellsmith.pages.dev/cli)
58
77
 
59
- ## 🐍 Python API Usage
78
+ ## MCP Integration
60
79
 
61
- You can also use `shellsmith` as a Python client library to interact with the BaSyx Environment REST API.
80
+ Shellsmith provides a Model Context Protocol (MCP) server that enables AI assistants to interact with Asset Administration Shells. The server exposes 25+ tools for comprehensive AAS management through a standardized interface.
62
81
 
63
- ```python
64
- import shellsmith
82
+ Configure with Claude Desktop or other MCP clients to get AI-powered AAS operations.
65
83
 
66
- # Fetch all AAS Shells
67
- shells = shellsmith.get_shells()
68
-
69
- # Fetch a specific Submodel
70
- submodel = shellsmith.get_submodel("https://example.com/submodels/my-submodel")
71
-
72
- # Read and update a Submodel Element's value
73
- value = shellsmith.get_submodel_element_value(submodel["id"], "temperature")
74
- shellsmith.patch_submodel_element_value(submodel["id"], "temperature", "42.0")
75
- ```
76
-
77
- > ℹ️ `shell_id` and `submodel_id` are automatically base64-encoded unless you pass `encode=False`.
78
-
79
- ➡️ Full Python API reference: [shellsmith.pages.dev/api](https://shellsmith.pages.dev/api)
84
+ ➡️ Full MCP reference: [shellsmith.pages.dev/mcp](https://shellsmith.pages.dev/mcp)
80
85
 
81
- ## 🔧 Configuration
86
+ ## Configuration
82
87
 
83
88
  The default AAS environment host is:
84
89
 
@@ -108,9 +113,9 @@ You can override it in several ways:
108
113
  shellsmith.get_shells(host="https://your-host:1234")
109
114
  ```
110
115
 
111
- > 💡 The `--host` CLI flag and `host=` Python argument **take precedence** over environment variables and `.env`.
116
+ > ℹ️ The `--host` CLI flag and `host=` Python argument **take precedence** over environment variables and `.env`.
112
117
 
113
- ## 🤝 Contributing
118
+ ## Contributing
114
119
 
115
120
  We welcome contributions!
116
121
 
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
  name = "shellsmith"
7
7
  dynamic = ["version"]
8
8
  authors = [{ name = "Peter Stein", email = "peter.stein@dfki.de" }]
9
- description = "A Python SDK and CLI for Eclipse BaSyx to manage Asset Administration Shells (AAS)"
9
+ description = "A Python SDK for Eclipse BaSyx to manage Asset Administration Shells (AAS)"
10
10
  license = { file = "LICENSE" }
11
11
  readme = { file = "README.md", content-type = "text/markdown" }
12
12
  requires-python = ">=3.10"
@@ -31,17 +31,13 @@ keywords = [
31
31
  "industry40",
32
32
  "i40",
33
33
  "digital-twin",
34
- "cli",
35
- "typer",
36
34
  "rest-client",
37
35
  "python",
38
36
  ]
39
37
  dependencies = [
40
38
  "httpx",
41
39
  "pydantic-settings",
42
- "fastmcp",
43
40
  "pyyaml",
44
- "typer",
45
41
  ]
46
42
 
47
43
  [project.optional-dependencies]
@@ -55,19 +51,21 @@ test = [
55
51
  "types-pyyaml",
56
52
  "types-requests"
57
53
  ]
54
+ cli = [
55
+ "aas-cli",
56
+ ]
58
57
  docs = [
59
58
  "mkdocs",
60
59
  "mkdocs-material",
61
60
  "termynal",
62
61
  ]
62
+ mcp = [
63
+ "aas-mcp",
64
+ ]
63
65
  neo4j = [
64
66
  "neo4j",
65
67
  ]
66
68
 
67
- [project.scripts]
68
- aas = "shellsmith.cli.app:main"
69
- shellsmith-mcp = "shellsmith.mcp.server:cli_main"
70
-
71
69
  [project.urls]
72
70
  Homepage = "https://github.com/SmartFactory-KL/shellsmith"
73
71
  Issues = "https://github.com/SmartFactory-KL/shellsmith/issues"
File without changes
@@ -1,44 +0,0 @@
1
- """Main CLI entry point for shellsmith with Typer."""
2
-
3
- import httpx
4
- import typer
5
-
6
- from .commands.decode import app as decode_app
7
- from .commands.encode import app as encode_app
8
- from .commands.groups.create import app as create_app
9
- from .commands.groups.delete import app as delete_app
10
- from .commands.groups.get import app as get_app
11
- from .commands.groups.update import app as update_app
12
- from .commands.info import app as info_app
13
- from .commands.nuke import app as nuke_app
14
- from .commands.upload import app as upload_app
15
-
16
- app = typer.Typer(
17
- help="shellsmith - AAS Toolkit command-line interface.",
18
- no_args_is_help=True,
19
- )
20
-
21
- app.add_typer(upload_app)
22
- app.add_typer(info_app)
23
- app.add_typer(nuke_app)
24
- app.add_typer(encode_app)
25
- app.add_typer(decode_app)
26
- app.add_typer(get_app)
27
- app.add_typer(delete_app)
28
- app.add_typer(update_app)
29
- app.add_typer(create_app)
30
-
31
-
32
- def main() -> None:
33
- """Main entry point for the CLI."""
34
- try:
35
- app()
36
- except httpx.ConnectError as e:
37
- typer.secho(f"😩 {e}", fg=typer.colors.RED)
38
- except Exception as e:
39
- typer.secho(f"💥 Unexpected error: {e}", fg=typer.colors.RED)
40
- raise
41
-
42
-
43
- if __name__ == "__main__":
44
- main()
@@ -1,30 +0,0 @@
1
- """Reusable CLI arguments in commands."""
2
-
3
- import typer
4
-
5
- SHELL_ID: typer.Argument = typer.Argument(
6
- ...,
7
- help="The unique identifier of the Shell.",
8
- )
9
-
10
- SUBMODEL_ID: typer.Argument = typer.Argument(
11
- ...,
12
- help="The unique identifier of the Submodel.",
13
- )
14
-
15
- ID_SHORT_PATH: typer.Argument = typer.Argument(
16
- ...,
17
- help="The idShort path for the Submodel Element.",
18
- )
19
-
20
- OPTIONAL_ID_SHORT_PATH: typer.Argument = typer.Argument(
21
- None,
22
- help="Optional idShort path for a nested Submodel Element.",
23
- )
24
-
25
- AAS_PATH: typer.Argument = typer.Argument(
26
- ...,
27
- help="The path to the AAS file or folder to upload. Accepts: .json, .xml, .aasx",
28
- )
29
-
30
- VALUE: typer.Argument = typer.Argument(..., help="The new value as string.")
File without changes
@@ -1,13 +0,0 @@
1
- """CLI command for base64-decoding unique identifiers."""
2
-
3
- import typer
4
-
5
- from shellsmith.utils import base64_decode
6
-
7
- app = typer.Typer()
8
-
9
-
10
- @app.command()
11
- def decode(value: str) -> None:
12
- """Decodes a Base64 value."""
13
- print(base64_decode(value))
@@ -1,13 +0,0 @@
1
- """CLI command for base64-encoding unique identifiers."""
2
-
3
- import typer
4
-
5
- from shellsmith.utils import base64_encode
6
-
7
- app = typer.Typer()
8
-
9
-
10
- @app.command("encode")
11
- def encode(value: str) -> None:
12
- """Encodes a value to Base64."""
13
- print(base64_encode(value))
@@ -1,79 +0,0 @@
1
- """CLI commands for creating Shells, Submodels, and Submodel Elements."""
2
-
3
- from pathlib import Path
4
-
5
- import typer
6
-
7
- from shellsmith import api
8
- from shellsmith.cli import args, opts
9
- from shellsmith.cli.handlers import handle_http_error
10
- from shellsmith.cli.pretty import make_label
11
- from shellsmith.cli.resolve import resolve_input
12
-
13
- app = typer.Typer(
14
- name="create",
15
- no_args_is_help=True,
16
- help="Create Shells, Submodels and Submodel elements.",
17
- )
18
-
19
-
20
- @app.command("shell")
21
- @handle_http_error()
22
- def create_shell(
23
- data: str | None = opts.DATA,
24
- file: Path | None = opts.FILE,
25
- host: str = opts.HOST,
26
- ) -> None:
27
- """🔹 Create a Shell from a data payload."""
28
- payload = resolve_input(data, file)
29
- created = api.create_shell(payload, host=host)
30
- label = make_label(created)
31
- typer.secho(f"✅ Created Shell: {label}", fg=typer.colors.GREEN)
32
-
33
-
34
- @app.command("submodel-ref")
35
- @handle_http_error()
36
- def create_submodel_ref(
37
- shell_id: str = args.SHELL_ID,
38
- data: str | None = opts.DATA,
39
- file: Path | None = opts.FILE,
40
- host: str = opts.HOST,
41
- ) -> None:
42
- """🔹 Create a Submodel reference for a Shell."""
43
- payload = resolve_input(data, file)
44
- api.create_submodel_ref(shell_id, payload, host=host)
45
- message = f"✅ Created Submodel reference in Shell: {shell_id}"
46
- typer.secho(message, fg=typer.colors.GREEN)
47
-
48
-
49
- @app.command("submodel")
50
- @handle_http_error()
51
- def create_submodel(
52
- data: str | None = opts.DATA,
53
- file: Path | None = opts.FILE,
54
- host: str = opts.HOST,
55
- ) -> None:
56
- """🔸 Create a Submodel from a data payload."""
57
- payload = resolve_input(data, file)
58
- created = api.create_submodel(payload, host=host)
59
- label = make_label(created)
60
- typer.secho(f"✅ Created Submodel: {label}", fg=typer.colors.GREEN)
61
-
62
-
63
- @app.command("element")
64
- @handle_http_error()
65
- def create_element(
66
- submodel_id: str = args.SUBMODEL_ID,
67
- id_short_path: str | None = args.OPTIONAL_ID_SHORT_PATH,
68
- data: str | None = opts.DATA,
69
- file: Path | None = opts.FILE,
70
- host: str = opts.HOST,
71
- ) -> None:
72
- """🔻 Create a Submodel Element (root or nested)."""
73
- payload = resolve_input(data, file)
74
- api.create_submodel_element(submodel_id, payload, id_short_path, host=host)
75
- label = (
76
- f"nested Element: {id_short_path}" if id_short_path else "root-level Element"
77
- )
78
- message = f"✅ Created {label} in Submodel: {submodel_id}"
79
- typer.secho(message, fg=typer.colors.GREEN)
@@ -1,83 +0,0 @@
1
- """CLI commands for deleting Shells, Submodels, and Submodel Elements."""
2
-
3
- import typer
4
-
5
- from shellsmith import api
6
- from shellsmith.cli import args, opts
7
- from shellsmith.cli.handlers import handle_http_error
8
- from shellsmith.cli.pretty import make_label
9
- from shellsmith.extract import collect_submodel_ids
10
-
11
- app = typer.Typer(
12
- name="delete",
13
- no_args_is_help=True,
14
- help="Delete Shells, Submodels and Submodel elements.",
15
- )
16
-
17
-
18
- @app.command("shell")
19
- @handle_http_error()
20
- def delete_shell(
21
- shell_id: str = args.SHELL_ID,
22
- cascade: bool = opts.CASCADE,
23
- host: str = opts.HOST,
24
- ) -> None:
25
- """🔹 Delete a Shell by ID, optionally with its referenced Submodels."""
26
- if cascade:
27
- shell = api.get_shell(shell_id, host=host)
28
- submodel_ids = collect_submodel_ids(shell)
29
-
30
- for submodel_id in submodel_ids:
31
- api.delete_submodel(submodel_id, host=host)
32
- message = f"✅ Deleted referenced Submodel: {submodel_id}"
33
- typer.secho(message, fg=typer.colors.YELLOW)
34
-
35
- api.delete_shell(shell_id, host=host)
36
- typer.secho(f"✅ Deleted Shell: {shell_id}", fg=typer.colors.GREEN)
37
-
38
-
39
- @app.command("submodel-ref")
40
- @handle_http_error()
41
- def delete_submodel_ref(
42
- shell_id: str = args.SHELL_ID,
43
- submodel_id: str = args.SUBMODEL_ID,
44
- host: str = opts.HOST,
45
- ) -> None:
46
- """🔹 Delete a Submodel reference from a Shell."""
47
- api.delete_submodel_ref(shell_id, submodel_id, host=host)
48
- message = f"✅ Deleted Submodel reference: {submodel_id} from Shell: {shell_id}"
49
- typer.secho(message, fg=typer.colors.GREEN)
50
-
51
-
52
- @app.command("submodel")
53
- @handle_http_error()
54
- def delete_submodel(
55
- submodel_id: str = args.SUBMODEL_ID,
56
- remove_refs: bool = opts.REMOVE_REFS,
57
- host: str = opts.HOST,
58
- ) -> None:
59
- """🔸 Delete a Submodel by ID."""
60
- if remove_refs:
61
- shells = api.get_shells(host=host)["result"]
62
- for shell in shells:
63
- if submodel_id in collect_submodel_ids(shell):
64
- label = make_label(shell)
65
- api.delete_submodel_ref(shell["id"], submodel_id)
66
- message = f"🔗 Removed reference from Shell {label}"
67
- typer.secho(message, fg=typer.colors.YELLOW)
68
-
69
- api.delete_submodel(submodel_id, host=host)
70
- message = f"✅ Deleted Submodel: {submodel_id}"
71
- typer.secho(message, fg=typer.colors.GREEN)
72
-
73
-
74
- @app.command("element")
75
- def delete_element(
76
- submodel_id: str = args.SUBMODEL_ID,
77
- id_short_path: str = args.ID_SHORT_PATH,
78
- host: str = opts.HOST,
79
- ) -> None:
80
- """🔻 Delete a Submodel Element by idShort path."""
81
- api.delete_submodel_element(submodel_id, id_short_path, host=host)
82
- message = f"✅ Deleted Element {id_short_path} from Submodel {submodel_id}"
83
- typer.secho(message, fg=typer.colors.GREEN)