|
9 | 9 |
|
10 | 10 | # Configure connection to SystemLink server |
11 | 11 | server_configuration = HttpConfiguration( |
12 | | - server_uri="https://test-api.lifecyclesolutions.ni.com/", |
13 | | - api_key="9voCglXGPBxU6-ZIQyFEwmIAymkdn_ynqOO7t52q2v", |
| 12 | + server_uri="https://yourserver.yourcompany.com", |
| 13 | + api_key="YourAPIKeyGeneratedFromSystemLink", |
14 | 14 | ) |
15 | 15 |
|
16 | 16 | client = FileClient(configuration=server_configuration) |
|
26 | 26 |
|
27 | 27 | # Wait for the file to be indexed for search |
28 | 28 | # Note: Files may take a few seconds to appear in search results after upload |
29 | | -print("Waiting 5 seconds for file to be indexed for search...") |
30 | 29 | time.sleep(5) |
31 | 30 | print() |
32 | 31 |
|
|
89 | 88 |
|
90 | 89 | # Example 4: Search by multiple custom properties |
91 | 90 | print("\nExample 4: Search by multiple custom properties") |
92 | | -# First upload a file with custom properties for demonstration |
93 | | -print("Uploading file with custom properties...") |
94 | | -test_file_2 = io.BytesIO(b"Custom properties test file") |
95 | | -test_file_2.name = "custom-props-test.txt" |
96 | | -file_id_2 = client.upload_file(file=test_file_2) |
97 | | - |
98 | | -# Update the file with custom properties |
| 91 | +print("Adding custom properties to existing file...") |
99 | 92 |
|
| 93 | +# Update the existing file with custom properties |
100 | 94 | custom_metadata = UpdateMetadataRequest( |
101 | 95 | replace_existing=False, |
102 | 96 | properties={ |
103 | 97 | "TestProperty1": "TestValue1", |
104 | 98 | "TestProperty2": "TestValue2", |
105 | 99 | }, |
106 | 100 | ) |
107 | | -client.update_metadata(metadata=custom_metadata, id=file_id_2) |
| 101 | +client.update_metadata(metadata=custom_metadata, id=file_id) |
108 | 102 |
|
109 | 103 | # Wait for indexing |
110 | | -print("Waiting 5 seconds for custom properties to be indexed...") |
111 | 104 | time.sleep(5) |
112 | 105 |
|
113 | 106 | # Search by multiple custom properties using AND operator |
|
129 | 122 | print(f" TestProperty1: {file.properties.get('TestProperty1')}") |
130 | 123 | print(f" TestProperty2: {file.properties.get('TestProperty2')}") |
131 | 124 |
|
132 | | -# Clean up: delete both test files |
| 125 | +# Clean up: delete the test file |
133 | 126 | print("\nCleaning up...") |
134 | 127 | client.delete_file(id=file_id) |
135 | | -client.delete_file(id=file_id_2) |
136 | | -print(f"Deleted test files with IDs: {file_id}, {file_id_2}") |
| 128 | +print(f"Deleted test file with ID: {file_id}") |
0 commit comments