Skip to content

Public API Entry Points

Public Root Client

nexthink_api.Clients.NexthinkClient

Bases: NxtApiClient

Public root client for the cleaned 0.1.0 API.

Compatibility Facade

nexthink_api.Clients.NxtApiClient

Initializes a new instance of the NxtApiClient class.

Parameters

instance : str
    The name of the Nexthink instance.
region : NxtRegionName
    The region of the Nexthink instance.
client_id : str
    The client ID for authentication.
client_secret : str
    The client secret for authentication.
proxies : Optional[dict]
    A dictionary of proxies to use for the requests. Defaults to None.
Note.
  • if proxy are not provided, it will try to detect proxies from environment variables
  • if no proxy are detected, it will disable the proxy
  • false value disable the proxy

settings = NxtSettings(instance=instance, region=region, proxies=proxies) instance-attribute

transport = NxtHttpTransport(base_url=str(self.settings.infinity_base_uri), proxies=self.settings.proxies, timeout=300) instance-attribute

token_provider = NxtTokenProvider(settings=self.settings, transport=self.transport, client_id=client_id, client_secret=client_secret) instance-attribute

endpoint: NxtEndpoint instance-attribute

token: Union[NxtTokenResponse, None] = None instance-attribute

headers = {} instance-attribute

enrichment: NxtEnrichmentClient property

Return the Enrichment domain client.

nql: NxtNqlClient property

Return the NQL domain client.

data_management: NxtDataManagementClient property

Return the Data Management domain client.

remote_actions: NxtRemoteActionsClient property

Return the Remote Actions domain client.

campaigns: NxtCampaignsClient property

Return the Campaigns domain client.

workflows: NxtWorkflowsClient property

Return the Workflows domain client.

spark: NxtSparkClient property

Return the Spark domain client.

init_token(client_id: str, client_secret: str) -> None

Initialize the token using the provided client ID and client secret.

Parameters
client_id : str
    The client ID.
client_secret : str
    The client secret.
Returns
None

update_header(endpoint: NxtEndpoint = None) -> None

Update header for subsequent requests based on the given endpoint.

Parameters
endpoint : NxtEndpoint, optional
    The endpoint type for which to update the header. Defaults to None.
Returns
None

create_autorisation(client_id: str, client_secret: str) -> None

Create authorization using client ID and client secret.

Parameters
client_id : str
    The client ID.
client_secret :str
    The client secret.
Returns
None

get_bearer_token() -> bool

Retrieve a bearer token from the server.

Returns
bool
    True if the token was successfully retrieved, False otherwise.
Raises
NxtTokenException
    If an error occurs during the token retrieval.

run_enrichment(endpoint: NxtEndpoint, data: NxtEnrichmentRequest) -> EnrichmentResponseType

Run an enrichment request on the specified endpoint using the provided data.

Parameter
endpoint : NxtEndpoint
    The endpoint to run the enrichment request on.
data : NxtEnrichmentRequest
    The data containing the enrichment request.
Raises
ValueError
    If the specified HTTP method is not supported.
Returns
EnrichmentResponseType
    The EnrichmentResponseType object containing the response from the API call.

run_nql(endpoint: NxtEndpoint, data: NxtNqlApiExecuteRequest, method: Optional[str] = None) -> NqlResponseType

Run an NQL query on the specified endpoint using the provided data.

Parameters
endpoint : NxtEndpoint
    The endpoint to run the NQL query on.
data NxtNqlApiExecuteRequest
    The data containing the NQL query.
method : Optional[str], optional
    The HTTP method to use for the request. Defaults to 'POST'.
Raises
ValueError
    If the specified HTTP method is not supported.
Returns
NqlResponseType
    The nql response object containing the response from the API call.

delete_devices(devices: list[NxtDeviceEntry], request_id: Optional[str] = None, uid_validation: NxtUidValidationMode = NxtUidValidationMode.WARN) -> DataManagementResponseType

Schedule device deletions through the Data Management API.

Parameters
devices : list[NxtDeviceEntry]
    Devices to delete from the Nexthink inventory.
request_id : Optional[str], optional
    Optional x-request-id correlation UUID. Defaults to None.
uid_validation : NxtUidValidationMode, optional
    Local UID validation mode. Defaults to WARN.
Returns
DataManagementResponseType
    Data Management response object returned by the API.
Raises
ValueError
    If POST is not supported or STRICT UID validation detects malformed UIDs.

validate_device_uids(devices: list[NxtDeviceEntry], uid_validation: NxtUidValidationMode) -> None staticmethod

Validate Data Management device UIDs according to the provided mode.

is_valid_uuid(value: str) -> bool staticmethod

Return True if value is a valid UUID.

wait_status(value: NxtNqlApiExportResponse, timeout: int = 300) -> Union[NxtNqlApiStatusResponse, NxtErrorResponse]

Wait for the status of an NQL API export request to complete.

Parameters
value : NxtNqlApiExportResponse
    The export request to check the status of.
timeout : int, optional
    The maximum time to wait for the status to complete. Defaults to 300.
Returns
Union[NxtNqlApiStatusResponse, NxtErrorResponse]
    The final status response of the export request.

get_status_export(value: NxtNqlApiExportResponse) -> NqlResponseType

Retrieve the status of an export based on the provided NxtNqlApiExportResponse value.

Constructs the export status URL and makes a GET request to fetch the status. Converts the response to a NxtNqlStatus object and returns it.

Parameters
value : NxtNqlApiExportResponse
    The export response object containing export ID.
Returns
NqlResponseType
    The status of the export operation.

download_export(value: NxtNqlApiStatusResponse, timeout: int = 300) -> requests.models.Response

Download an export file based on the NxtNqlApiStatusResponse value and a timeout period.

Parameters
value : NxtNqlApiStatusResponse
    The status response object containing the export details.
timeout : int, optional
    The timeout period for the download request in seconds. Defaults to 300.
Returns
requests.models.Response
    The response object from the download request.

download_export_as_df(value: NxtNqlApiStatusResponse, timeout: int = 300) -> pd.DataFrame

Download an export file as a pandas DataFrame based on the NxtNqlApiStatusResponse and a timeout period.

Parameters
value : NxtNqlApiStatusResponse
    The status response object containing the export details.
timeout : int, optional
    The timeout period for the download request in seconds. Defaults to 300.
Returns
pd.DataFrame
    The downloaded dataframe.

check_method(endpoint: NxtEndpoint, method: str) -> bool

Check if a given method is supported for a specific endpoint.

Parameters
endpoint : NxtEndpoint
    The endpoint to check the method for.
method : str
    The method to check.
Returns
bool
    True if the method is supported, False otherwise.

get(endpoint: NxtEndpoint, params=None) -> ResponseApiType

Send a GET request to the specified endpoint with optional query parameters.

Parameters
endpoint : NxtEndpoint
    The endpoint to send the request to.
params : Optional[Dict[str, Any]]
    Query parameters to include in the request. Defaults to None.
Returns
ResponseAPIType
    The response object containing the status of the request.
Raises
requests.exceptions.RequestException
    If there was an error sending the request.

post(endpoint: NxtEndpoint, data: Union[NxtTokenRequest, NxtEnrichmentRequest, NxtNqlApiExecuteRequest, NxtDeviceDeletionRequest], headers: Optional[dict[str, str]] = None) -> ResponseApiType

Send a POST request to the specified endpoint with the provided data.

Parameters
endpoint : (NxtEndpoint
    The endpoint to send the request to.
data : Union[NxtTokenRequest, NxtEnrichmentRequest, NxtNqlApiExecuteRequest, NxtDeviceDeletionRequest])
    The data to be sent in the request.
headers : Optional[dict[str, str]]
    Extra headers for this request. Defaults to None.
Returns
 ResponseAPIType
    The response object containing the status of the POST request.

Official Domain Entry Points

Domain clients are created by NexthinkClient and accessed through properties:

client.enrichment.run(request)
client.nql.execute(request)
client.data_management.delete_devices(devices)
client.remote_actions.list()
client.campaigns.trigger(request)
client.workflows.execute(request)
client.spark.handoff(request, user_principal_name="user@example.com")

The implementation classes behind those properties are internal delegates. Use the domain pages for request and response models.