listOrganizations method

Future<Organizations?> listOrganizations({
  1. bool? includeMembersCount,
  2. bool? includeMissingMemberWithElevatedPermissions,
  3. String? query,
  4. List<String>? userId,
  5. List<String>? organizationId,
  6. String? orderBy,
  7. int? limit,
  8. int? offset,
})

Get a list of organizations for an instance

This request returns the list of organizations for an instance. Results can be paginated using the optional limit and offset query parameters. The organizations are ordered by descending creation date. Most recent organizations will be returned first.

Parameters:

  • bool includeMembersCount: Flag to denote whether the member counts of each organization should be included in the response or not.

  • bool includeMissingMemberWithElevatedPermissions: Flag to denote whether or not to include a member with elevated permissions who is not currently a member of the organization.

  • String query: Returns organizations with ID, name, or slug that match the given query. Uses exact match for organization ID and partial match for name and slug.

  • List<String> userId: Returns organizations with the user ids specified. Any user ids not found are ignored. For each user id, the + and - can be prepended to the id, which denote whether the respective organization should be included or excluded from the result set.

  • List<String> organizationId: Returns organizations with the organization ids specified. Any organization ids not found are ignored. For each organization id, the + and - can be prepended to the id, which denote whether the respective organization should be included or excluded from the result set. Accepts up to 100 organization ids. Example: ?organization_id=+org_1&organization_id=-org_2

  • String orderBy: Allows to return organizations in a particular order. At the moment, you can order the returned organizations either by their name, created_at or members_count. In order to specify the direction, you can use the +/- symbols prepended in the property to order by. For example, if you want organizations to be returned in descending order according to their created_at property, you can use -created_at. If you don't use + or -, then + is implied. Defaults to -created_at.

  • int limit: Applies a limit to the number of results returned. Can be used for paginating the results together with offset.

  • int offset: Skip the first offset results when paginating. Needs to be an integer greater or equal to zero. To be used in conjunction with limit.

Implementation

Future<Organizations?> listOrganizations({
  bool? includeMembersCount,
  bool? includeMissingMemberWithElevatedPermissions,
  String? query,
  List<String>? userId,
  List<String>? organizationId,
  String? orderBy,
  int? limit,
  int? offset,
}) async {
  final response = await listOrganizationsWithHttpInfo(
    includeMembersCount: includeMembersCount,
    includeMissingMemberWithElevatedPermissions:
        includeMissingMemberWithElevatedPermissions,
    query: query,
    userId: userId,
    organizationId: organizationId,
    orderBy: orderBy,
    limit: limit,
    offset: offset,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty &&
      response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'Organizations',
    ) as Organizations;
  }
  return null;
}