Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions nisystemlink/clients/assetmanagement/models/_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Dict, List

from nisystemlink.clients.core._uplink._json_model import JsonModel
from pydantic import Field
from pydantic import AliasChoices, Field

from ._asset_calibration import (
CalibrationStatus,
Expand Down Expand Up @@ -68,17 +68,25 @@ class Asset(JsonModel):
self_calibration: SelfCalibration | None = None
"""Gets or sets the last self-calibration of the asset."""

is_NI_asset: bool | None = Field(alias="isNIAsset", default=None)
is_ni_asset: bool | None = Field(
default=None,
validation_alias=AliasChoices("is_ni_asset", "is_NI_asset", "isNIAsset"),
serialization_alias="isNIAsset",
)
"""Gets or sets whether this asset is an NI asset (true) or a third-party asset (false)."""

id: str | None = None
"""Gets or sets unique identifier of the asset."""

location: AssetLocation | None = None
"""Model for information about the asset location, presence and the connection status of the system"""
"""Model for information about the asset location, presence,
and the connection status of the system.
"""

calibration_status: CalibrationStatus | None = None
"""Gets or sets the calibration category the asset belongs to based on the next due calibration date."""
"""Gets or sets the calibration category the asset belongs to
based on the next due calibration date.
"""

is_system_controller: bool | None = None
"""Gets or sets whether this asset represents a System Controller."""
Expand All @@ -96,7 +104,9 @@ class Asset(JsonModel):
"""Gets or sets words or phrases associated with an asset."""

last_updated_timestamp: datetime | None = None
"""Gets or sets ISO-8601 formatted timestamp specifying the last date that the asset has had a property update."""
"""Gets or sets an ISO-8601 timestamp for the last date
that the asset had a property update.
"""

file_ids: List[str] | None = None
"""Gets or sets all files linked to the asset."""
Expand Down
22 changes: 13 additions & 9 deletions nisystemlink/clients/assetmanagement/models/_asset_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ class AssetPresenceStatus(Enum):


class SystemConnection(Enum):
"""Whether or not the minion is connected to the server and has updated the server with its data.
To maintain compatibility with previous versions of SystemLink, the values
[APPROVED, UNSUPPORTED, ACTIVATED] are considered equivalent to DISCONNECTED and
[CONNECTED_UPDATE_PENDING, CONNECTED_UPDATE_SUCCESSFUL, CONNECTED_UPDATE_FAILED] are equivalent to CONNECTED.
"""Whether the minion is connected to the server.

For backward compatibility, APPROVED, UNSUPPORTED, and ACTIVATED are
treated as DISCONNECTED. CONNECTED_UPDATE_PENDING,
CONNECTED_UPDATE_SUCCESSFUL, and CONNECTED_UPDATE_FAILED are treated
as CONNECTED.
"""

APPROVED = "APPROVED"
Expand All @@ -30,13 +32,15 @@ class SystemConnection(Enum):


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

asset_presence: AssetPresenceStatus
"""Gets or sets the status of an asset's presence in a system."""

system_connection: SystemConnection | None = None
"""Gets or sets whether or not the minion is connected to the server and has updated the server with its data."""
"""Gets or sets whether the minion is connected to the server
and has updated it with its data.
"""


class AssetPresence(JsonModel):
Expand All @@ -47,7 +51,7 @@ class AssetPresence(JsonModel):


class _AssetLocation(JsonModel):
"""local model for information about the asset location, presence and the connection status of the system."""
"""Local model for asset location and presence information."""

minion_id: str | None = None
"""Gets or sets identifier of the minion where the asset is located."""
Expand All @@ -66,14 +70,14 @@ class _AssetLocation(JsonModel):


class AssetLocation(_AssetLocation):
"""Model for information about the asset location, presence and the connection status of the system."""
"""Asset location and system connection information."""

state: AssetPresenceWithSystemConnection
"""Presence of an asset and the connection of the system in which it resides."""


class AssetLocationForCreate(_AssetLocation):
"""Model for information about the asset presence status of the system, used while create"""
"""Asset presence information used during create."""

state: AssetPresence
"""Model for the presence of an asset."""
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Dict, List

from nisystemlink.clients.core._uplink._json_model import JsonModel
from pydantic import Field
from pydantic import AliasChoices, Field

from ._asset import (
AssetBusType,
Expand Down Expand Up @@ -65,14 +65,20 @@ class CreateAssetRequest(JsonModel):
self_calibration: SelfCalibration | None = None
"""Gets or sets the last self-calibration of the asset."""

is_NI_asset: bool | None = Field(alias="isNIAsset", default=None)
is_ni_asset: bool | None = Field(
default=None,
validation_alias=AliasChoices("is_ni_asset", "is_NI_asset", "isNIAsset"),
serialization_alias="isNIAsset",
)
"""Gets or sets whether this asset is an NI asset (true) or a third-party asset (false)."""

workspace: str | None = None
"""Gets or sets the ID of the workspace."""

location: AssetLocationForCreate
"""Model for information about the asset location, presence and the connection status of the system"""
"""Model for information about the asset location, presence,
and the connection status of the system.
"""

external_calibration: ExternalCalibration | None = None
"""Gets or sets the last external calibration of the asset."""
Expand Down
15 changes: 13 additions & 2 deletions nisystemlink/clients/core/_uplink/_json_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseModel, ConfigDict
from pydantic import AliasChoices, AliasGenerator, BaseModel, ConfigDict


def _camelcase(s: str) -> str:
Expand All @@ -7,11 +7,22 @@ def _camelcase(s: str) -> str:
return next(parts) + "".join(i.title() for i in parts)


def _validation_aliases(s: str) -> str | AliasChoices:
"""Accept both Python snake_case and wire-format camelCase inputs."""
camelcase = _camelcase(s)
if camelcase == s:
return s
return AliasChoices(s, camelcase)


class JsonModel(BaseModel):
"""Base class for models that are serialized to and from JSON."""

model_config = ConfigDict(
alias_generator=_camelcase,
alias_generator=AliasGenerator(
validation_alias=_validation_aliases,
serialization_alias=_camelcase,
),
validate_by_name=True,
validate_by_alias=True,
extra="ignore",
Expand Down
9 changes: 7 additions & 2 deletions nisystemlink/clients/file/models/_file_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Dict

from nisystemlink.clients.core._uplink._json_model import JsonModel
from pydantic import Field
from pydantic import AliasChoices, Field

from ._link import Link

Expand Down Expand Up @@ -53,8 +53,13 @@ class BaseFileMetadata(JsonModel):


class FileMetadata(BaseFileMetadata):
"""Metadata for a file."""

field_links: Dict[str, Link] | None = Field(None, alias="_links")
field_links: Dict[str, Link] | None = Field(
None,
validation_alias=AliasChoices("field_links", "_links"),
serialization_alias="_links",
)
"""
The links to access and manipulate the file:
- data: Link to download the file using a GET request
Expand Down
9 changes: 6 additions & 3 deletions nisystemlink/clients/file/models/_file_query_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
from typing import Dict, List

from nisystemlink.clients.core._uplink._json_model import JsonModel
from pydantic import Field
from pydantic import AliasChoices, Field

from ._file_metadata import FileMetadata
from ._link import Link


class FileQueryResponse(JsonModel):
"""The result of a file query"""
"""The result of a file query."""

field_links: Dict[str, Link] = Field(alias="_links")
field_links: Dict[str, Link] = Field(
validation_alias=AliasChoices("field_links", "_links"),
serialization_alias="_links",
)
"""The links that apply to the collection of files for a service group:
- deleteFiles: Link to delete multiple files from the service group using a POST
- query: Link to query for available files in the service group using a POST
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from datetime import datetime

from nisystemlink.clients.core._uplink._json_model import JsonModel
from pydantic import Field
from pydantic import AliasChoices, Field


class UploadSessionStartResponse(JsonModel):
"""Response model for starting an upload session."""

session_id: str = Field(alias="id")
session_id: str = Field(
validation_alias=AliasChoices("session_id", "id"),
serialization_alias="id",
)
"""
The id created for the upload session.
"""
Expand Down
34 changes: 23 additions & 11 deletions nisystemlink/clients/notebook/models/_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
from typing import Any, Dict

from nisystemlink.clients.core._uplink._json_model import JsonModel
from pydantic import Field
from pydantic import AliasChoices, Field


class SourceType(str, Enum):
"""Source type of an execution"""
"""Source type of an execution."""

MANUAL = "MANUAL"

TRIGGERED = "TRIGGERED"


class Source(JsonModel):
"""An object that defines properties set by routine service"""
"""An object that defines properties set by routine service."""

type: SourceType
"""Source type of an execution"""
Expand All @@ -38,13 +38,13 @@ class ReportType(str, Enum):


class ReportSettings(JsonModel):
"""A class that defines settings of the Report"""
"""A class that defines settings of the Report."""

format: ReportType
"""Type for the report that is going to be generated."""

exclude_code: bool
"""Boolean parameter that will define if the source code should be included in the report or not."""
"""Whether the source code should be included in the report."""


class ExecutionPriority(str, Enum):
Expand All @@ -58,6 +58,7 @@ class ExecutionPriority(str, Enum):


class ExecutionResourceProfile(str, Enum):
"""Resource profile of the execution. Can be one of Low, Medium, High or Default."""

DEFAULT = "DEFAULT"

Expand Down Expand Up @@ -109,30 +110,41 @@ class ExecutionErrorCode(str, Enum):


class Execution(JsonModel):
"""Information about an execution of a Jupyter notebook that has the cachedResult field added."""
"""Jupyter notebook execution information.

Includes the cachedResult field.
"""

id: str | None = None
"""The ID of the execution."""

notebook_id: str | None = None
"""The ID of the executed notebook."""

organization_id: str | None = Field(None, alias="orgId")
organization_id: str | None = Field(
None,
validation_alias=AliasChoices("organization_id", "orgId"),
serialization_alias="orgId",
)
"""The org ID of the user creating the request."""

user_id: str | None = None
"""The user ID of the user creating the request."""

parameters: Dict[str, Any] | None = None
"""The input parameters for this execution of the notebook. The keys are strings and the values can be of any
valid JSON type."""
"""The input parameters for this execution.

The keys are strings and the values can be any valid JSON type.
"""

workspace_id: str | None = None
"""The ID of the workspace this execution belongs to."""

timeout: int | None = None
"""The number of seconds the execution runs before it aborts if uncompleted. The timer starts once status is
IN_PROGRESS. 0 means infinite."""
"""The number of seconds the execution runs before it aborts.

The timer starts once status is IN_PROGRESS. 0 means infinite.
"""

status: ExecutionStatus | None = None
"""Status of an execution."""
Expand Down
Loading
Loading