findSourcesForTarget method

Future<RelationArray> findSourcesForTarget({
  1. required String relationName,
  2. required String sourceType,
  3. required String targetType,
  4. required String targetKey,
  5. String? sourceStatus,
  6. String? targetStatus,
  7. int? sourceVersion,
  8. int? targetVersion,
  9. List<String>? expand,
  10. int? start,
  11. int? limit,
})

Returns all target entities that have a particular relationship to the source entity. Note, relationships are one way.

For example, the following method finds all users that have a 'collaborator' relationship to a piece of content with an ID of '1234': GET /wiki/rest/api/relation/collaborator/to/content/1234/from/user Note, 'collaborator' is an example custom relationship type.

Permissions required: Permission to view both the target entity and source entity.

Implementation

Future<RelationArray> findSourcesForTarget(
    {required String relationName,
    required String sourceType,
    required String targetType,
    required String targetKey,
    String? sourceStatus,
    String? targetStatus,
    int? sourceVersion,
    int? targetVersion,
    List<String>? expand,
    int? start,
    int? limit}) async {
  return RelationArray.fromJson(await _client.send(
    'get',
    'wiki/rest/api/relation/{relationName}/to/{targetType}/{targetKey}/from/{sourceType}',
    pathParameters: {
      'relationName': relationName,
      'sourceType': sourceType,
      'targetType': targetType,
      'targetKey': targetKey,
    },
    queryParameters: {
      if (sourceStatus != null) 'sourceStatus': sourceStatus,
      if (targetStatus != null) 'targetStatus': targetStatus,
      if (sourceVersion != null) 'sourceVersion': '$sourceVersion',
      if (targetVersion != null) 'targetVersion': '$targetVersion',
      if (expand != null) 'expand': expand.map((e) => e).join(','),
      if (start != null) 'start': '$start',
      if (limit != null) 'limit': '$limit',
    },
  ));
}