getProjectsSites method

Future<List<ProjectsSite>?> getProjectsSites()

Returns the org's deployed sites at the pretty URLs they serve at.

Returns the org's deployed sites at the pretty URLs they serve at. It reads the SAME org-scoped store as /v1/projects and keeps only the projects that are actually live, so a draft or a failed build is not advertised as a site. Scope: a validated principal is required (403 without one) and the list is keyed by that principal's org.

Implementation

Future<List<ProjectsSite>?> getProjectsSites() async {
  final response = await getProjectsSitesWithHttpInfo();
  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) {
    final responseBody = await _decodeBodyBytes(response);
    return (await apiClient.deserializeAsync(responseBody, 'List<ProjectsSite>') as List)
      .cast<ProjectsSite>()
      .toList(growable: false);

  }
  return null;
}