sendConnectorEvent method

Future<SendConnectorEventResponse> sendConnectorEvent({
  1. required String connectorId,
  2. required ConnectorEventOperation operation,
  3. String? connectorDeviceId,
  4. String? deviceDiscoveryId,
  5. List<Device>? devices,
  6. MatterEndpoint? matterEndpoint,
  7. String? message,
  8. String? operationVersion,
  9. int? statusCode,
  10. String? traceId,
  11. String? userId,
})

Relays third-party device events for a connector such as a new device or a device state change event.

May throw AccessDeniedException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceUnavailableException. May throw ThrottlingException. May throw ValidationException.

Parameter connectorId : The id of the connector between the third-party cloud provider and IoT managed integrations.

Parameter operation : The Open Connectivity Foundation (OCF) operation requested to be performed on the managed thing.

Parameter connectorDeviceId : The third-party device id as defined by the connector. This device id must not contain personal identifiable information (PII).

Parameter deviceDiscoveryId : The id for the device discovery job.

Parameter devices : The list of devices.

Parameter matterEndpoint : The device endpoint.

Parameter message : The device state change event payload.

This parameter will include the following three fields:

  • uri: schema auc://<PARTNER-DEVICE-ID>/ResourcePath (The Resourcepath corresponds to an OCF resource.)
  • op: For device state changes, this field must populate as n+d.
  • cn: The content depends on the OCF resource referenced in ResourcePath.

Parameter operationVersion : The Open Connectivity Foundation (OCF) security specification version for the operation being requested on the managed thing. For more information, see OCF Security Specification.

Parameter statusCode : The status code of the Open Connectivity Foundation (OCF) operation being performed on the managed thing.

Parameter traceId : The trace request identifier. This is generated by IoT managed integrations and can be used to trace this command and its related operations in CloudWatch.

Parameter userId : The id of the third-party cloud provider.

Implementation

Future<SendConnectorEventResponse> sendConnectorEvent({
  required String connectorId,
  required ConnectorEventOperation operation,
  String? connectorDeviceId,
  String? deviceDiscoveryId,
  List<Device>? devices,
  MatterEndpoint? matterEndpoint,
  String? message,
  String? operationVersion,
  int? statusCode,
  String? traceId,
  String? userId,
}) async {
  _s.validateNumRange(
    'statusCode',
    statusCode,
    100,
    550,
  );
  final $payload = <String, dynamic>{
    'Operation': operation.value,
    if (connectorDeviceId != null) 'ConnectorDeviceId': connectorDeviceId,
    if (deviceDiscoveryId != null) 'DeviceDiscoveryId': deviceDiscoveryId,
    if (devices != null) 'Devices': devices,
    if (matterEndpoint != null) 'MatterEndpoint': matterEndpoint,
    if (message != null) 'Message': message,
    if (operationVersion != null) 'OperationVersion': operationVersion,
    if (statusCode != null) 'StatusCode': statusCode,
    if (traceId != null) 'TraceId': traceId,
    if (userId != null) 'UserId': userId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/connector-event/${Uri.encodeComponent(connectorId)}',
    exceptionFnMap: _exceptionFns,
  );
  return SendConnectorEventResponse.fromJson(response);
}