TopicClient¶
Namespace: IntegrationTests.ApiClient
Inheritance Object → TopicClient
Properties¶
BaseUrl¶
Property Value¶
ReadResponseAsString¶
Property Value¶
Constructors¶
TopicClient(String, HttpClient)¶
Parameters¶
baseUrl String
httpClient HttpClient
Methods¶
CreateTopicAsync(TopicSetting)¶
Creates a new MQTT topic configuration for sensor monitoring.
Parameters¶
topicSetting TopicSetting
The complete topic setting configuration to create.
Returns¶
Topic setting created successfully. Returns the new topic ID.
Exceptions¶
ApiException
A server side error occurred.
Remarks:
This endpoint allows administrators to add new sensor configurations to the monitoring system.
Each topic setting maps a physical sensor to its MQTT topic and location within the building.
Authorization Required: Bearer token with Admin role
Required Fields:
- sensorName: Unique identifier for the sensor (e.g., "TempSensor_03")
- sensorLocation: Physical location (e.g., "North", "South", "East", "West", "Center")
- mqttTopic: MQTT topic path for this sensor (e.g., "sensors/temperature/east")
Example Request:
json <br>{ <br>"sensorName": "TempSensor_03", <br>"sensorLocation": "East", <br>"mqttTopic": "sensors/temperature/east", <br>"isActive": true, <br>"description": "Temperature sensor in the eastern section" <br>} <br>
Example Response:
json <br>{ <br>"id": 3, <br>"message": "Topic created successfully" <br>} <br>
Validation Rules:
- Sensor names must be unique across the system
- MQTT topics should follow the pattern: sensors/temperature/{location}
- Location names should be descriptive and consistent
CreateTopicAsync(TopicSetting, CancellationToken)¶
Creates a new MQTT topic configuration for sensor monitoring.
public Task<Object> CreateTopicAsync(TopicSetting topicSetting, CancellationToken cancellationToken)
Parameters¶
topicSetting TopicSetting
The complete topic setting configuration to create.
cancellationToken CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns¶
Topic setting created successfully. Returns the new topic ID.
Exceptions¶
ApiException
A server side error occurred.
Remarks:
This endpoint allows administrators to add new sensor configurations to the monitoring system.
Each topic setting maps a physical sensor to its MQTT topic and location within the building.
Authorization Required: Bearer token with Admin role
Required Fields:
- sensorName: Unique identifier for the sensor (e.g., "TempSensor_03")
- sensorLocation: Physical location (e.g., "North", "South", "East", "West", "Center")
- mqttTopic: MQTT topic path for this sensor (e.g., "sensors/temperature/east")
Example Request:
json <br>{ <br>"sensorName": "TempSensor_03", <br>"sensorLocation": "East", <br>"mqttTopic": "sensors/temperature/east", <br>"isActive": true, <br>"description": "Temperature sensor in the eastern section" <br>} <br>
Example Response:
json <br>{ <br>"id": 3, <br>"message": "Topic created successfully" <br>} <br>
Validation Rules:
- Sensor names must be unique across the system
- MQTT topics should follow the pattern: sensors/temperature/{location}
- Location names should be descriptive and consistent
DeleteTopicAsync(TopicSetting)¶
Deletes an existing MQTT topic setting from the system.
Parameters¶
topicSetting TopicSetting
The topic setting object identifying the configuration to delete.
Returns¶
Successfully deleted the topic setting.
Exceptions¶
ApiException
A server side error occurred.
DeleteTopicAsync(TopicSetting, CancellationToken)¶
Deletes an existing MQTT topic setting from the system.
public Task<Object> DeleteTopicAsync(TopicSetting topicSetting, CancellationToken cancellationToken)
Parameters¶
topicSetting TopicSetting
The topic setting object identifying the configuration to delete.
cancellationToken CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns¶
Successfully deleted the topic setting.
Exceptions¶
ApiException
A server side error occurred.
GetAllSensorTypesAsync()¶
Retrieves all available sensor types from the system.
Returns¶
Successfully retrieved the list of sensor types.
Exceptions¶
ApiException
A server side error occurred.
GetAllSensorTypesAsync(CancellationToken)¶
Retrieves all available sensor types from the system.
Parameters¶
cancellationToken CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns¶
Successfully retrieved the list of sensor types.
Exceptions¶
ApiException
A server side error occurred.
GetAllTopicsAsync()¶
Retrieves all configured MQTT topic settings from the system.
Returns¶
Successfully retrieved all topic settings.
Exceptions¶
ApiException
A server side error occurred.
Remarks:
This endpoint returns all MQTT topic configurations including:
- Sensor names and their physical locations (North, South, etc.)
- MQTT topic mappings for each sensor
- Configuration metadata for the monitoring system
Authorization Required: Bearer token with Admin role
This information is essential for:
- System administration and configuration management
- Troubleshooting sensor connectivity issues
- Understanding the current sensor topology
Example Response:
json <br>[ <br>{ <br>"id": 1, <br>"sensorName": "TempSensor_01", <br>"sensorLocation": "North", <br>"mqttTopic": "sensors/temperature/north", <br>"isActive": true <br>}, <br>{ <br>"id": 2, <br>"sensorName": "TempSensor_02", <br>"sensorLocation": "South", <br>"mqttTopic": "sensors/temperature/south", <br>"isActive": true <br>} <br>] <br>
GetAllTopicsAsync(CancellationToken)¶
Retrieves all configured MQTT topic settings from the system.
Parameters¶
cancellationToken CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns¶
Successfully retrieved all topic settings.
Exceptions¶
ApiException
A server side error occurred.
Remarks:
This endpoint returns all MQTT topic configurations including:
- Sensor names and their physical locations (North, South, etc.)
- MQTT topic mappings for each sensor
- Configuration metadata for the monitoring system
Authorization Required: Bearer token with Admin role
This information is essential for:
- System administration and configuration management
- Troubleshooting sensor connectivity issues
- Understanding the current sensor topology
Example Response:
json <br>[ <br>{ <br>"id": 1, <br>"sensorName": "TempSensor_01", <br>"sensorLocation": "North", <br>"mqttTopic": "sensors/temperature/north", <br>"isActive": true <br>}, <br>{ <br>"id": 2, <br>"sensorName": "TempSensor_02", <br>"sensorLocation": "South", <br>"mqttTopic": "sensors/temperature/south", <br>"isActive": true <br>} <br>] <br>
ReadObjectResponseAsync<T>(HttpResponseMessage, IReadOnlyDictionary<String, IEnumerable<String>>, CancellationToken)¶
protected Task<ObjectResponseResult<T>> ReadObjectResponseAsync<T>(HttpResponseMessage response, IReadOnlyDictionary<String, IEnumerable<String>> headers, CancellationToken cancellationToken)
Type Parameters¶
T
Parameters¶
response HttpResponseMessage
headers IReadOnlyDictionary<String, IEnumerable<String>>
cancellationToken CancellationToken
Returns¶
Task<ObjectResponseResult<T>>
UpdateTopicAsync(TopicSetting)¶
Updates an existing MQTT topic setting in the system.
Parameters¶
topicSetting TopicSetting
The topic setting object containing updated configuration.
Returns¶
Successfully updated the topic setting.
Exceptions¶
ApiException
A server side error occurred.
UpdateTopicAsync(TopicSetting, CancellationToken)¶
Updates an existing MQTT topic setting in the system.
public Task<Object> UpdateTopicAsync(TopicSetting topicSetting, CancellationToken cancellationToken)
Parameters¶
topicSetting TopicSetting
The topic setting object containing updated configuration.
cancellationToken CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns¶
Successfully updated the topic setting.
Exceptions¶
ApiException
A server side error occurred.