|
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) |
0 commit comments