Skip to content

Nql Classes

nexthink_api.Nql

Classes in the module.

NxtDateTime

Bases: BaseModel

Datetime class object for NQL answer.

Attributes
year : int
    year (2 or 4 digits).
month : int
    month (1-12).
day : int
    day (1-31).
hour : int
    hour (0-23).
minute : int
    minute (0-59).
second : int
    second (0-59).
Raises
ValueError
    when year is not 2-digits or 4-digit number.

year: Annotated[int, Field(strict=True)] instance-attribute

month: Annotated[int, Field(strict=True, ge=1, le=12)] instance-attribute

day: Annotated[int, Field(strict=True, ge=1, le=31)] instance-attribute

hour: Annotated[int, Field(strict=True, ge=0, le=23)] instance-attribute

minute: Annotated[int, Field(strict=True, ge=0, le=59)] instance-attribute

second: Annotated[int, Field(strict=True, ge=0, le=59)] instance-attribute

validate_year(value: int) -> int classmethod

Ensure year is 2-digit or 4-digit.

Parameters
value : int
    year to validate.
Returns
int
    valid year.
Raises
ValueError
    when year is not 2-digits or 4-digit number.

validate_date() -> Self

Verify is a date can be created with these parameters.

NxtErrorResponse

Bases: BaseModel

An error response for NQL request.

Attributes
message: str
    Message with the description of the error
code: int
    Error code
source: Optional[str]
    Source of the error, if any

message: str instance-attribute

code: int instance-attribute

source: Optional[str] = None class-attribute instance-attribute

NxtNqlApiExecuteRequest

Bases: BaseModel

Represent a NQL request object.

Attributes:

queryId : str Identifier of the query which is going to be executed. parameters : dict[str, str] The parameters of the query.

Note:

The queryId is a string, with a maximum length of 255 characters, composed of alphanumeric characters (a-z, A-Z, 0-9), underscores (_), and start with a sharp character (#).

The parameters is a dictionary of string keys and string values.

queryId: Annotated[str, Field(min_length=2, pattern='^#[a-z0-9_]{1,255}$')] instance-attribute

parameters: dict[str, str] = Field(default={}) class-attribute instance-attribute

NxtNqlApiExecuteResponse

Bases: BaseModel

NQL Class answer object for V1 request.

Parameters
queryId: str
    Identifier of the executed query.
executedQuery: str
    Final query executed with the replaced parameters.
rows: int
    Number of rows returned
executionDateTime: NxtDateTime
    Date and time of the execution

queryId: str instance-attribute

executedQuery: str instance-attribute

rows: NonNegativeInt instance-attribute

executionDateTime: NxtDateTime instance-attribute

headers: list[str] instance-attribute

data: list[list] instance-attribute

NxtNqlApiExportResponse

Bases: BaseModel

Class for the NQL API export response.

Attributes

exportId : str Identifier of the query which is going to be executed.

exportId: Annotated[str, Field(min_length=1)] instance-attribute

NxtNqlApiStatusResponse

Bases: BaseModel

Response status of an NQL API request.

Attributes
status : NxtNqlStatus
    Status of the NQL API request.
resultsFileUrl : Optional[HttpUrl]
    URL of the file with the content once the export has been completed.
errorDescription : Optional[str]
    Message with the description of the error.

status: NxtNqlStatus instance-attribute

resultsFileUrl: Optional[HttpUrl] = None class-attribute instance-attribute

errorDescription: Optional[str] = None class-attribute instance-attribute

serialize_status(value: NxtNqlStatus) -> str

Serialize the status attribute to its value when used in JSON format.

Parameters
value : NxtNqlStatus
    Value to be serialized.
Returns
str
    Serialized value of the status attribute.

NxtNqlStatus

Bases: str, Enum

NQL Status response state.

SUBMITTED = 'SUBMITTED' class-attribute instance-attribute

IN_PROGRESS = 'IN_PROGRESS' class-attribute instance-attribute

ERROR = 'ERROR' class-attribute instance-attribute

COMPLETED = 'COMPLETED' class-attribute instance-attribute

NxtNqlApiExecuteV2Response

Bases: BaseModel

NQL API execute V2 response.

Attributes

queryId : str Identifier of the executed query. executedQuery : str Final query executed with the replaced parameters. rows : int Number of rows returned executionDateTime : str Date and time of the execution in ISO 8601 format (YYYY-MM-DDThh🇲🇲ss.sssTZD). data : List[dict[str, str]] List of dictionaries representing the rows of the query result.

queryId: str instance-attribute

executedQuery: str instance-attribute

rows: int instance-attribute

executionDateTime: str instance-attribute

data: List[dict[str, str]] instance-attribute

parse_execution_datetime(value: str) -> str classmethod

Parse the execution date time from ISO 8601 format (YYYY-MM-DDThh🇲🇲ss.sssTZD).

Parameters
value (str): Value to be parsed.
Returns
str: Parsed datetime object.
Raises
ValueError: If the value is not in ISO 8601 format.