findTargetFromSource method

Future<RelationArray> findTargetFromSource({
  1. required String relationName,
  2. required String sourceType,
  3. required String sourceKey,
  4. required String targetType,
  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 content that the current user has an 'ignore' relationship with: GET /wiki/rest/api/relation/ignore/from/user/current/to/content Note, 'ignore' is an example custom relationship type.

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

Implementation

Future<RelationArray> findTargetFromSource(
    {required String relationName,
    required String sourceType,
    required String sourceKey,
    required String targetType,
    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}/from/{sourceType}/{sourceKey}/to/{targetType}',
    pathParameters: {
      'relationName': relationName,
      'sourceType': sourceType,
      'sourceKey': sourceKey,
      'targetType': targetType,
    },
    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',
    },
  ));
}