Skip to content

MindConnect Client for Python

Introduction

The MindConnect Python client allows you to interact with MindConnect Service APIs which enables shop floor devices to send data securely and reliably to MindSphere. Refer to MindConnect for more information about the service.

Hint

Placeholders in the following samples are indicated by angular brackets < >.

Mindconnect Operations

Client Name: DiagnosticActivationsClient

Gets diagnostic activations

Get diagnostic activations. Agents are allowed to get their own activation. Users with sufficient scopes are allowed to get all activations in the same tenant as in the token.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Import the RestClientConfig and UserToken from mindsphere_core module
from mindsphere_core import RestClientConfig
from mindsphere_core import UserToken

# Import the MindsphereError from mindsphere_core.exceptions module
from mindsphere_core.exceptions import MindsphereError

# Import the DiagnosticActivationsClient from mindconnect module
from mindconnect.clients.diagnostic_activation_client import DiagnosticActivationsClient


# Create the DiagnosticActivationsClient object using the RestClientConfig and UserToken objects
diagnosticActivationsClient = DiagnosticActivationsClient(rest_client_config = config, mindsphere_credentials = credentials)

try:
    # Create the request object
    request_object = DiagnosticActivationsGetRequest()

    # Initiate the API call
    response = diagnosticActivationsClient.diagnostic_activations_get(request_object)

except MindsphereError as err:
    # Exception Handling

Creates a new diagnostic activation

Create a new diagnostic activation. Agents are allowed to create activation for itself only. Users with sufficient scopes are allowed to create activations of the agents in the same tenant as in the token.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
try:
    # Create the request object
    diagnosticActivation = DiagnosticActivation(
            agent_id="078b1908bc9347678168760934465587",
            status="ACTIVE"
        )
    request_object = DiagnosticActivationsPostRequest(
            diagnostic_activation=diagnosticActivation
        )

    # Initiate the API call
    response = diagnosticActivationsClient.diagnostic_activations_post(request_object)

except MindsphereError as err:
    # Exception Handling

Deletes a diagnostic activation

Delete a diagnostic activation. Agents are allowed to delete their own activation. Users with sufficient scopes are allowed to delete any activation in the same tenant as in the token.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
try:
    # Create the request object
    request_object = DiagnosticActivationsIdDeleteRequest(
            id="078b1908bc9347678168760934465587"
        )

    # Initiate the API call
    response = diagnosticActivationsClient.diagnostic_activations_id_delete(request_object)

except MindsphereError as err:
    # Exception Handling

Gets a diagnostic activation by ID

Get a diagnostic activation with given id. Agents are allowed to get their own activation. Users with sufficient scopes are allowed to get any activation in the same tenant as in the token.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
try:
    # Create the request object
    request_object = DiagnosticActivationsIdGetRequest(
            id="078b1908bc9347678168760934465587"
        )

    # Initiate the API call
    response = diagnosticActivationsClient.diagnostic_activations_id_get(request_object)

except MindsphereError as err:
    # Exception Handling

Get a diagnostic messages of specific activation resource

Get a diagnostic messages of specific activation resource. Agents are allowed to get their own activations' messages. Users with sufficient scopes are allowed to get any activations messages in the same tenant as in the token.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
try:
    # Create the request object
    request_object = DiagnosticActivationsIdMessagesGetRequest(
            id="078b1908bc9347678168760934465587"
        )

    # Initiate the API call
    response = diagnosticActivationsClient.diagnostic_activations_id_messages_get(request_object)

except MindsphereError as err:
    # Exception Handling

Update status of Diagnostic Activation

Get a diagnostic messages of specific activation resource. Agents are allowed to get their own activations' messages. Users with sufficient scopes are allowed to get any activations messages in the same tenant as in the token.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
try:
    # Create the request object
    diagnosticActivationStatus = DiagnosticActivationStatus(
            status="INACTIVE"
        )
    request_object = DiagnosticActivationsIdPutRequest(
            id="078b1908bc9347678168760934465587",
            diagnostic_activation_status=diagnosticActivationStatus
        )

    # Initiate the API call
    response = diagnosticActivationsClient.diagnostic_activations_id_put(request_object)

except MindsphereError as err:
    # Exception Handling

Client Name: DiagnosticInformationClient

Get Diagnostic Information

This operation is deprecated! Use \"/diagnosticActivations/{id}/messages\" instead. Gets Diagnostic Information.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Import the DiagnosticInformationClient from mindconnect module
from mindconnect.clients.diagnostic_information_client import DiagnosticInformationClient


# Create the DiagnosticInformationClient object using the RestClientConfig and UserToken objects
diagnosticInformationClient = DiagnosticInformationClient(rest_client_config = config, mindsphere_credentials = credentials)

try:
    # Create the request object
    requestObject = DiagnosticInformationGetRequest()

    # Initiate the API call
    response = diagnosticInformationClient.diagnostic_information_get(request_object)

except MindsphereError as err:
    # Exception Handling

Client Name: MappingsClient

Get mappings.

Retrieves a list of mappings.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Import the MappingsClient from mindconnect module
from mindconnect.clients.mapping_client import MappingsClient


# Create the MappingsClient object using the RestClientConfig and UserToken objects
mappingsClient = MappingsClient(rest_client_config = config, mindsphere_credentials = credentials)

try:
    # Create the request object
    request_object = DataPointMappingsGetRequest()

    # Initiate the API call
    response = mappingsClient.data_point_mappings_get(request_object)

except MindsphereError as err:
    # Exception Handling

Get a mapping by id

Gets a mapping by given id.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
try:
    # Create the request object
    request_object = DataPointMappingsIdGetRequest(
            id="7d3aef34-268f-4d00-b23f-91c50ff945fb"
        )

    # Initiate the API call
    response = mappingsClient.data_point_mappings_id_get(request_object)

except MindsphereError as err:
    # Exception Handling

Create single mapping

Creates a single mapping.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
try:
    # Create the request object
    mapping = Mapping(
            agent_id="ad22f8a7ebb24b8fb41767afd2c63f08",
            data_point_id="SDKDP13",
            entity_id="078b1908bc9347678168760934465587",
            property_set_name="TyreTemperature",
            property_name="FLWheel",
            keep_mapping=False
        )
    request_object = DataPointMappingsPostRequest(
            mapping=mapping
        )

    # Initiate the API call
    response = mappingsClient.data_point_mappings_post(request_object)

except MindsphereError as err:
    # Exception Handling

Delete a mapping

Deletes a mapping.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
try:
    # Create the request object
    request_object = DataPointMappingsIdDeleteRequest(
            id="7ec593ef-14d8-47ef-ad5a-c091320c4e06"
        )

    # Initiate the API call
    response = mappingsClient.data_point_mappings_id_delete(request_object)

except MindsphereError as err:
    # Exception Handling

Client Name: RecordRecoveryClient

Re-play a recoverable record

Re-play a recoverable record.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Import the RecordRecoveryClient from mindconnect module
from mindconnect.clients.record_recovery_client import RecordRecoveryClient


# Create the RecordRecoveryClient object using the RestClientConfig and UserToken objects
recordRecoveryClient = RecordRecoveryClient(rest_client_config = config, mindsphere_credentials = credentials)

try:
    # Create the request object
    request_object = RecoverableRecordsIdReplayPostRequest(
            id="078b1908bc934767816876093446558"
        )

    # Initiate the API call
    response = recordRecoveryClient.recoverable_records_id_replay_post(request_object)

except MindsphereError as err:
    # Exception Handling

Get all recoverable records

Gets all recoverable records.

1
2
3
4
5
6
7
8
9
try:
    # Create the request object
    request_object = RecoverableRecordsGetRequest()

    # Initiate the API call
    response = recordRecoveryClient.recoverable_records_get(request_object)

except MindsphereError as err:
    # Exception Handling

Gets download link of record payload.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
try:
    # Create the request object
    request_object = RecoverableRecordsIdDownloadLinkGetRequest(
            id="078b1908bc934767816876093446558"
        )

    # Initiate the API call
    response = recordRecoveryClient.recoverable_records_id_download_link_get(request_object)

except MindsphereError as err:
    # Exception Handling

Delete a recoverable record

Deletes a recoverable record.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
try:
    # Create the request object
    request_object = RecoverableRecordsIdDeleteRequest(
            id="078b1908bc934767816876093446558"
        )

    # Initiate the API call
    response = recordRecoveryClient.recoverable_records_id_delete(request_object)

except MindsphereError as err:
    # Exception Handling

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.