Skip to content

Commit 9e3da3c

Browse files
author
Aravindhan Palanisamy
committed
resolved PR comments
1 parent 493ba46 commit 9e3da3c

File tree

5 files changed

+34
-19
lines changed

5 files changed

+34
-19
lines changed

examples/assetmanagement/assets.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
from nisystemlink.clients.assetmanagement.models import (
33
AssetBusType,
44
AssetDiscoveryType,
5-
AssetLocation,
6-
AssetPresence,
7-
AssetPresenceWithSystemConnection,
5+
AssetLocationForCreate,
6+
AssetPresenceStatus,
87
AssetType,
98
CreateAssetRequest,
109
ExternalCalibration,
@@ -45,10 +44,8 @@
4544
),
4645
is_NI_asset=True,
4746
workspace="846e294a-a007-47ac-9fc2-fac07eab240e",
48-
location=AssetLocation(
49-
state=AssetPresenceWithSystemConnection(
50-
asset_presence=AssetPresence.PRESENT
51-
)
47+
location=AssetLocationForCreate(
48+
state=AssetLocationForCreate(asset_presence=AssetPresenceStatus.PRESENT)
5249
),
5350
external_calibration=ExternalCalibration(
5451
temperature_sensors=[TemperatureSensor(name="Sensor0", reading=25.8)],

nisystemlink/clients/assetmanagement/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
from ._query_assets_response import QueryAssetsResponse
88
from ._asset_location import (
99
AssetLocation,
10+
AssetLocationForCreate,
1011
AssetPresence,
1112
AssetPresenceWithSystemConnection,
13+
AssetPresenceStatus,
1214
)
1315
from ._asset_calibration import (
1416
CalibrationMode,

nisystemlink/clients/assetmanagement/models/_asset_location.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from nisystemlink.clients.core._uplink._json_model import JsonModel
55

66

7-
class AssetPresence(Enum):
7+
class AssetPresenceStatus(Enum):
88
"""Status of an asset's presence in a system."""
99

1010
INITIALIZING = "INITIALIZING"
@@ -20,20 +20,33 @@ class SystemConnection(Enum):
2020
[CONNECTED_UPDATE_PENDING, CONNECTED_UPDATE_SUCCESSFUL, CONNECTED_UPDATE_FAILED] are equivalent to CONNECTED.
2121
"""
2222

23-
CONNECTED = "CONNECTED"
23+
APPROVED = "APPROVED"
2424
DISCONNECTED = "DISCONNECTED"
25+
CONNECTED_UPDATE_PENDING = "CONNECTED_UPDATE_PENDING"
26+
CONNECTED = "CONNECTED"
27+
CONNECTED_UPDATE_FAILED = "CONNECTED_UPDATE_FAILED"
28+
UNSUPPORTED = "UNSUPPORTED"
29+
ACTIVATED = "ACTIVATED"
30+
CONNECTED_UPDATE_SUCCESSFUL = "CONNECTED_UPDATE_SUCCESSFUL"
2531

2632

2733
class AssetPresenceWithSystemConnection(JsonModel):
2834
"""Model for the presence of an asset and the connection of the system in which it resides."""
2935

30-
asset_presence: AssetPresence
36+
asset_presence: AssetPresenceStatus
3137
"""Gets or sets the status of an asset's presence in a system."""
3238

3339
system_connection: Optional[SystemConnection] = None
3440
"""Gets or sets whether or not the minion is connected to the server and has updated the server with its data."""
3541

3642

43+
class AssetPresence(JsonModel):
44+
"""Model for the presence of an asset."""
45+
46+
asset_presence: AssetPresenceStatus
47+
"""Gets or sets the status of an asset's presence in a system."""
48+
49+
3750
class AssetLocation(JsonModel):
3851
"""Model for information about the asset location, presence and the connection status of the system."""
3952

@@ -54,3 +67,8 @@ class AssetLocation(JsonModel):
5467

5568
state: AssetPresenceWithSystemConnection
5669
"""Presence of an asset and the connection of the system in which it resides."""
70+
71+
72+
class AssetLocationForCreate(AssetLocation):
73+
74+
state: AssetPresence

nisystemlink/clients/assetmanagement/models/_create_asset_request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
from ._asset import (
66
AssetBusType,
77
AssetDiscoveryType,
8-
AssetLocation,
98
AssetType,
109
ExternalCalibration,
1110
SelfCalibration,
1211
TemperatureSensor,
1312
)
13+
from ._asset_location import AssetLocationForCreate
1414

1515

1616
class CreateAssetRequest(JsonModel):
@@ -70,7 +70,7 @@ class CreateAssetRequest(JsonModel):
7070
workspace: Optional[str] = None
7171
"""Gets or sets the ID of the workspace."""
7272

73-
location: AssetLocation
73+
location: AssetLocationForCreate
7474
"""Model for information about the asset location, presence and the connection status of the system"""
7575

7676
external_calibration: Optional[ExternalCalibration] = None

tests/integration/assetmanagement/test_asset_management.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
AssetBusType,
99
AssetDiscoveryType,
1010
AssetField,
11-
AssetLocation,
11+
AssetLocationForCreate,
1212
AssetPresence,
13-
AssetPresenceWithSystemConnection,
13+
AssetPresenceStatus,
1414
AssetType,
1515
CreateAssetRequest,
1616
CreateAssetsPartialSuccessResponse,
@@ -49,10 +49,8 @@ def create_assets_request() -> List[CreateAssetRequest]:
4949
),
5050
is_NI_asset=True,
5151
workspace="846e294a-a007-47ac-9fc2-fac07eab240e",
52-
location=AssetLocation(
53-
state=AssetPresenceWithSystemConnection(
54-
asset_presence=AssetPresence.PRESENT
55-
)
52+
location=AssetLocationForCreate(
53+
state=AssetPresence(asset_presence=AssetPresenceStatus.PRESENT)
5654
),
5755
external_calibration=ExternalCalibration(
5856
temperature_sensors=[TemperatureSensor(name="Sensor0", reading=25.8)],
@@ -83,7 +81,7 @@ def create_asset(client: AssetManagementClient):
8381
def _create_assets(
8482
new_assets: CreateAssetRequest,
8583
) -> CreateAssetsPartialSuccessResponse:
86-
response = client.create_assets(assets = new_assets)
84+
response = client.create_assets(assets=new_assets)
8785
responses.append(response)
8886
return response
8987

0 commit comments

Comments
 (0)