|
31 | 31 |
|
32 | 32 | client = AssetManagementClient(configuration=server_configuration) |
33 | 33 |
|
34 | | -create_assets_request = [ |
35 | | - CreateAssetRequest( |
36 | | - model_number=4000, |
37 | | - model_name="NI PXIe-6368", |
38 | | - serial_number="01BB877A", |
39 | | - vendor_name="NI", |
40 | | - vendor_number=4244, |
41 | | - bus_type=AssetBusType.ACCESSORY, |
42 | | - name="PCISlot2", |
43 | | - asset_type=AssetType.DEVICE_UNDER_TEST, |
44 | | - firmware_version="A1", |
45 | | - hardware_version="12A", |
46 | | - visa_resource_name="vs-3144", |
| 34 | +create_asset_request = CreateAssetRequest( |
| 35 | + model_number=4000, |
| 36 | + model_name="NI PXIe-6368", |
| 37 | + serial_number="01BB877A", |
| 38 | + vendor_name="NI", |
| 39 | + vendor_number=4244, |
| 40 | + bus_type=AssetBusType.ACCESSORY, |
| 41 | + name="PCISlot2", |
| 42 | + asset_type=AssetType.DEVICE_UNDER_TEST, |
| 43 | + firmware_version="A1", |
| 44 | + hardware_version="12A", |
| 45 | + visa_resource_name="vs-3144", |
| 46 | + temperature_sensors=[TemperatureSensor(name="Sensor0", reading=25.8)], |
| 47 | + supports_self_calibration=True, |
| 48 | + supports_external_calibration=True, |
| 49 | + custom_calibration_interval=24, |
| 50 | + self_calibration=SelfCalibration( |
47 | 51 | temperature_sensors=[TemperatureSensor(name="Sensor0", reading=25.8)], |
48 | | - supports_self_calibration=True, |
49 | | - supports_external_calibration=True, |
50 | | - custom_calibration_interval=24, |
51 | | - self_calibration=SelfCalibration( |
52 | | - temperature_sensors=[TemperatureSensor(name="Sensor0", reading=25.8)], |
53 | | - is_limited=False, |
54 | | - date=datetime(2022, 6, 7, 18, 58, 5, tzinfo=timezone.utc), |
55 | | - ), |
56 | | - is_NI_asset=True, |
57 | | - workspace=workspace_id, |
58 | | - location=AssetLocationForCreate( |
59 | | - state=AssetPresence(asset_presence=AssetPresenceStatus.PRESENT) |
| 52 | + is_limited=False, |
| 53 | + date=datetime(2022, 6, 7, 18, 58, 5, tzinfo=timezone.utc), |
| 54 | + ), |
| 55 | + is_NI_asset=True, |
| 56 | + workspace=workspace_id, |
| 57 | + location=AssetLocationForCreate( |
| 58 | + state=AssetPresence(asset_presence=AssetPresenceStatus.PRESENT) |
| 59 | + ), |
| 60 | + external_calibration=ExternalCalibration( |
| 61 | + temperature_sensors=[TemperatureSensor(name="Sensor0", reading=25.8)], |
| 62 | + date=datetime(2022, 6, 7, 18, 58, 5, tzinfo=timezone.utc), |
| 63 | + recommended_interval=10, |
| 64 | + next_recommended_date=datetime( |
| 65 | + 2023, 11, 14, 20, 42, 11, 583000, tzinfo=timezone.utc |
60 | 66 | ), |
61 | | - external_calibration=ExternalCalibration( |
62 | | - temperature_sensors=[TemperatureSensor(name="Sensor0", reading=25.8)], |
63 | | - date=datetime(2022, 6, 7, 18, 58, 5, tzinfo=timezone.utc), |
64 | | - recommended_interval=10, |
65 | | - next_recommended_date=datetime( |
66 | | - 2023, 11, 14, 20, 42, 11, 583000, tzinfo=timezone.utc |
67 | | - ), |
68 | | - next_custom_due_date=datetime( |
69 | | - 2024, 11, 14, 20, 42, 11, 583000, tzinfo=timezone.utc |
70 | | - ), |
71 | | - resolved_due_date=datetime(2022, 6, 7, 18, 58, 5, tzinfo=timezone.utc), |
| 67 | + next_custom_due_date=datetime( |
| 68 | + 2024, 11, 14, 20, 42, 11, 583000, tzinfo=timezone.utc |
72 | 69 | ), |
73 | | - properties={"Key1": "Value1"}, |
74 | | - keywords=["Keyword1"], |
75 | | - discovery_type=AssetDiscoveryType.MANUAL, |
76 | | - file_ids=["608a5684800e325b48837c2a"], |
77 | | - supports_self_test=True, |
78 | | - supports_reset=True, |
79 | | - part_number="A1234 B5", |
80 | | - ) |
81 | | -] |
| 70 | + resolved_due_date=datetime(2022, 6, 7, 18, 58, 5, tzinfo=timezone.utc), |
| 71 | + ), |
| 72 | + properties={"Key1": "Value1"}, |
| 73 | + keywords=["Keyword1"], |
| 74 | + discovery_type=AssetDiscoveryType.MANUAL, |
| 75 | + file_ids=["608a5684800e325b48837c2a"], |
| 76 | + supports_self_test=True, |
| 77 | + supports_reset=True, |
| 78 | + part_number="A1234 B5", |
| 79 | +) |
82 | 80 |
|
83 | 81 | # Create an asset. |
84 | | -create_assets_response = client.create_assets(assets=create_assets_request) |
85 | | - |
86 | | -created_asset_id = None |
87 | | -if create_assets_response.assets and len(create_assets_response.assets) > 0: |
88 | | - created_asset_id = str(create_assets_response.assets[0].id) |
| 82 | +created_asset = client.create_asset(asset=create_asset_request) |
| 83 | +created_asset_id = str(created_asset.id) |
89 | 84 |
|
90 | 85 | # Query assets using id. |
91 | 86 | query_asset_request = QueryAssetsRequest( |
|
0 commit comments