Skip to content

Commit 9b13e70

Browse files
Merge branch 'ni:master' into master
2 parents 3aae58f + 77021d3 commit 9b13e70

File tree

14 files changed

+203
-64
lines changed

14 files changed

+203
-64
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
<!--next-version-placeholder-->
44

5+
## v2.16.0 (2025-06-13)
6+
7+
### Feature
8+
9+
* Spec client | Add Get Spec API ([#147](https://github.com/ni/nisystemlink-clients-python/issues/147)) ([`b1ebf7c`](https://github.com/ni/nisystemlink-clients-python/commit/b1ebf7cb77f0be84e1e9a76afe52413c720bf0ea))
10+
11+
## v2.15.0 (2025-06-11)
12+
13+
### Feature
14+
15+
* Add delete API for Artifact client ([#142](https://github.com/ni/nisystemlink-clients-python/issues/142)) ([`22f6515`](https://github.com/ni/nisystemlink-clients-python/commit/22f6515bac2b298fb18468095d9a02c782f4f6fb))
16+
517
## v2.14.0 (2025-05-30)
618

719
### Feature

docs/api_reference.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ API Reference
1919
api_reference/assetmanagement
2020
api_reference/systems
2121
api_reference/test_plan
22+
api_reference/artifact
2223

2324
Indices and tables
2425
------------------

docs/api_reference/artifact.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.. _api_tag_page:
2+
3+
nisystemlink.clients.artifact
4+
======================
5+
6+
.. autoclass:: nisystemlink.clients.artifact.ArtifactClient
7+
:exclude-members: __init__
8+
9+
.. automethod:: __init__
10+
.. automethod:: upload_artifact
11+
.. automethod:: download_artifact
12+
.. automethod:: delete_artifact
13+
14+
.. automodule:: nisystemlink.clients.artifact.models
15+
:members:
16+
:imported-members:

docs/api_reference/spec.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ nisystemlink.clients.spec
1212
.. automethod:: delete_specs
1313
.. automethod:: query_specs
1414
.. automethod:: update_specs
15+
.. automethod:: get_spec
1516

1617
.. automodule:: nisystemlink.clients.spec.models
1718
:members:

docs/getting_started.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ With a :class:`.SpecClient` object, you can:
170170

171171
* Query for specifications on any fields using DynamicLinq syntax.
172172

173+
* Get a specification using an Id.
174+
173175
Examples
174176
~~~~~~~~
175177

176-
Create and Query Specifications
178+
Create, Get and Query Specifications
177179

178-
.. literalinclude:: ../examples/spec/query_specs.py
180+
.. literalinclude:: ../examples/spec/get_and_query_specs.py
179181
:language: python
180182
:linenos:
181183

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
import io
2-
3-
from nisystemlink.clients.artifact import ArtifactClient
4-
from nisystemlink.clients.core import HttpConfiguration
5-
6-
7-
# Setup the server configuration to point to your instance of SystemLink Enterprise
8-
server_configuration = HttpConfiguration(
9-
server_uri="https://yourserver.yourcompany.com",
10-
api_key="YourAPIKeyGeneratedFromSystemLink",
11-
)
12-
client = ArtifactClient(configuration=server_configuration)
13-
14-
# Define the workspace and artifact content
15-
workspace = "your workspace ID"
16-
artifact_stream = io.BytesIO(b"test content")
17-
18-
# Upload the artifact
19-
upload_response = client.upload_artifact(workspace=workspace, artifact=artifact_stream)
20-
if upload_response and upload_response.id:
21-
print(f"Uploaded artifact ID: {upload_response.id}")
22-
23-
# Download the artifact using the ID from the upload response
24-
artifact_id = upload_response.id
25-
download_response = client.download_artifact(artifact_id)
26-
if download_response:
27-
downloaded_content = download_response.read()
28-
print(f"Downloaded artifact content: {downloaded_content.decode('utf-8')}")
1+
import io
2+
3+
from nisystemlink.clients.artifact import ArtifactClient
4+
from nisystemlink.clients.core import HttpConfiguration
5+
6+
7+
# Setup the server configuration to point to your instance of SystemLink Enterprise
8+
server_configuration = HttpConfiguration(
9+
server_uri="https://yourserver.yourcompany.com",
10+
api_key="YourAPIKeyGeneratedFromSystemLink",
11+
)
12+
client = ArtifactClient(configuration=server_configuration)
13+
14+
# Define the workspace and artifact content
15+
workspace = "your workspace ID"
16+
artifact_stream = io.BytesIO(b"test content")
17+
18+
# Upload the artifact
19+
upload_response = client.upload_artifact(workspace=workspace, artifact=artifact_stream)
20+
if upload_response and upload_response.id:
21+
print(f"Uploaded artifact ID: {upload_response.id}")
22+
23+
# Download the artifact using the ID from the upload response
24+
artifact_id = upload_response.id
25+
download_response = client.download_artifact(artifact_id)
26+
if download_response:
27+
downloaded_content = download_response.read()
28+
print(f"Downloaded artifact content: {downloaded_content.decode('utf-8')}")
29+
30+
# Delete the artifact
31+
client.delete_artifact(artifact_id)
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@
6868
]
6969

7070
# Create the specs on the server
71-
client.create_specs(CreateSpecificationsRequest(specs=spec_requests))
71+
created_response = client.create_specs(CreateSpecificationsRequest(specs=spec_requests))
72+
73+
# use get for first spec created
74+
if created_response.created_specs and len(created_response.created_specs) > 0:
75+
created_spec = client.get_spec(created_response.created_specs[0].id)
7276

7377
# You can query specs based on any field using DynamicLinq syntax.
7478
# These are just some representative examples.

nisystemlink/clients/artifact/_artifact_client.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44

55
from nisystemlink.clients import core
66
from nisystemlink.clients.core._uplink._base_client import BaseClient
7-
from nisystemlink.clients.core._uplink._methods import get, post, response_handler
7+
from nisystemlink.clients.core._uplink._methods import (
8+
delete,
9+
get,
10+
post,
11+
response_handler,
12+
)
813
from nisystemlink.clients.core.helpers._iterator_file_like import IteratorFileLike
914
from requests.models import Response
1015
from uplink import Part, Path
@@ -81,3 +86,13 @@ def download_artifact(self, id: Path) -> IteratorFileLike:
8186
8287
"""
8388
...
89+
90+
@delete("artifacts/{id}", args=[Path("id")])
91+
def delete_artifact(self, id: str) -> None:
92+
"""Deletes an artifact.
93+
94+
Args:
95+
id: The ID of the artifact to delete.
96+
97+
"""
98+
...

nisystemlink/clients/spec/_spec_client.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ def query_specs(
9696
"""
9797
...
9898

99+
@get("specs/{id}")
100+
def get_spec(self, id: str) -> models.Specification:
101+
"""Retrieves a single spec by id.
102+
103+
Args:
104+
id (str): Unique ID of a specification.
105+
106+
Returns:
107+
The single spec matching `id`
108+
109+
Raises:
110+
ApiException: if unable to communicate with the `nispec` service or if there are invalid
111+
arguments.
112+
"""
113+
...
114+
99115
@post("update-specs")
100116
def update_specs(
101117
self, specs: models.UpdateSpecificationsRequest

poetry.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)