Skip to content

MindConnect Client for Java

Introduction

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

Further implementation of the MindConnect SDK library has been shown in a sample project that you can download and test in local or on Insights Hub application. Please refer to this repository: industrial-iot-java-sdk-examples

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.
// Construct the DiagnosticActivationsClient object
  DiagnosticActivationsClient diActivationsClient = DiagnosticActivationsClient.builder().restClientConfig(config).build();

  DiagnosticActivationsGetRequest requestObject = new DiagnosticActivationsGetRequest();

     try {
       PagedDiagnosticActivation response = diActivationsClient.diagnosticActivationsGet(requestObject);

      } catch (MindsphereException e) {
      // 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.
  DiagnosticActivationsPostRequest requestObject = new DiagnosticActivationsPostRequest();
  DiagnosticActivation diagnosticActivation = new DiagnosticActivation();
  diagnosticActivation.setAgentId("ef80c8aea3a74ad986d22376a7715df2");
  diagnosticActivation.setStatus(StatusEnum.fromValue("ACTIVE"));
  requestObject.setDiagnosticActivation(diagnosticActivation);

      try {
        DiagnosticActivation response = diActivationsClient.diagnosticActivationsPost(requestObject);
       } catch (MindsphereException e) {
       // 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.
  DiagnosticActivationsIdDeleteRequest requestObject = new DiagnosticActivationsIdDeleteRequest();
  requestObject.setId("ef80c8aea3a74ad986d22376a7715df2");

      try {
         diActivationsClient.diagnosticActivationsIdDelete(requestObject);
       } catch (MindsphereException e) {
       // 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.
  DiagnosticActivationsIdGetRequest requestObject = new DiagnosticActivationsIdGetRequest();
  requestObject.setId("ef80c8aea3a74ad986d22376a7715df2");

     try {
       DiagnosticActivation response = diActivationsClient.diagnosticActivationsIdGet(requestObject);
      } catch (MindsphereException e) {
      // 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.
  DiagnosticActivationsIdMessagesGetRequest requestObject = new DiagnosticActivationsIdMessagesGetRequest();
  requestObject.setId("ad22f8a7ebb24b8fb41767afd2c63f08");

     try {
       PagedDiagnosticInformationMessages response = diActivationsClient.diagnosticActivationsIdMessagesGet(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }

Update status of Diagnostic Activation

  • Updates status of Diagnostic Activation.
  DiagnosticActivationsIdPutRequest requestObject = new DiagnosticActivationsIdPutRequest();
  requestObject.setId("ad22f8a7ebb24b8fb41767afd2c63f08");
  DiagnosticActivationStatus diagnosticActivationStatus = new DiagnosticActivationStatus();
  diagnosticActivationStatus.setStatus(DiagnosticActivationStatus.StatusEnum.fromValue("ACTIVE"));
  requestObject.setDiagnosticActivationStatus(diagnosticActivationStatus);

     try {
       DiagnosticActivation response = diActivationsClient.diagnosticActivationsIdPut(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }

Client Name: MappingsClient

Get mappings

  • Retrieves a list of mappings.
// Construct the DiagnosticActivationsClient object
  MappingsClient mappingClient = MappingsClient.builder().restClientConfig(config).build();

  DataPointMappingsGetRequest dataPointMappingsGetRequest = new DataPointMappingsGetRequest();

     try {
       PagedMapping response = mappingClient.dataPointMappingsGet(dataPointMappingsGetRequest);
      } catch (MindsphereException e) {
      // Exception handling
      }

Get a mapping by id

  • Gets a mapping by given id.
  DataPointMappingsIdGetRequest requestObject = new DataPointMappingsIdGetRequest();
  requestObject.setId("c7d02a2f-c3cc-4a65-add6-2e71fa963a9f");

     try {
       Mapping response = mappingClient.dataPointMappingsIdGet(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }

Create single mapping

  • Creates a single mapping.
  DataPointMappingsPostRequest requestObject = new DataPointMappingsPostRequest();
  MappingPost mapping = new MappingPost();
  mapping.setAgentId("ad22f8a7ebb24b8fb41767afd2c63f08");
  mapping.setDataPointId("SDKDP13");
  mapping.setEntityId("078b1908bc9347678168760934465587");
  mapping.setPropertySetName("TyreTemperature");
  mapping.setPropertyName("FLWheel");
  mapping.setKeepMapping(false);
  requestObject.setMapping(mapping);

     try {
       Mapping response = mappingClient.dataPointMappingsPost(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }

Delete a mapping

  • Deletes a mapping.
  DataPointMappingsIdDeleteRequest requestObject = new DataPointMappingsIdDeleteRequest();
  requestObject.setId("2abe6a4f-1813-49c4-a5d2-b498582de98e");

     try {
       mappingClient.dataPointMappingsIdDelete(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }

Client Name: RecordRecoveryClient

Get all recoverable records

  • Gets all recoverable records
// Construct the DiagnosticActivationsClient object
  RecordRecoveryClient recoveryClient = RecordRecoveryClient.builder().restClientConfig(config).build();

  RecoverableRecordsGetRequest requestObject = new RecoverableRecordsGetRequest();

     try {
       PagedRecoverableRecords response = recoveryClient.recoverableRecordsGet(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }

Re-play a recoverable record

  • Re-play a recoverable record.
  RecoverableRecordsIdReplayPostRequest requestObject = new RecoverableRecordsIdReplayPostRequest();
  requestObject.setId("078b1908bc9347678168760934465587");

     try {
       recoveryClient.recoverableRecordsIdReplayPost(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }
  • Gets download link of record payload
  RecoverableRecordsIdDownloadLinkGetRequest requestObject = new RecoverableRecordsIdDownloadLinkGetRequest();
  requestObject.setId("078b1908bc9347678168760934465587");

     try {
       String response = recoveryClient.recoverableRecordsIdDownloadLinkGet(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }

Delete a recoverable record

  • Deletes a recoverable record
  RecoverableRecordsIdDeleteRequest requestObject = new RecoverableRecordsIdDeleteRequest();
  requestObject.setId("078b1908bc9347678168760934465587");

     try {
       recoveryClient.recoverableRecordsIdDelete(requestObject);
      } catch (MindsphereException e) {
      // Exception handling
      }

Community

Connect and Collaborate with Industrial Professionals and Join the Community!

Click to load comments