readFile method

Future<ReadRepositoryFileResponse> readFile(
  1. String name, {
  2. String? commitSha,
  3. String? path,
  4. String? $fields,
})

Returns the contents of a file (inside a Repository).

The Repository must not have a value for git_remote_settings.url.

Request parameters:

name - Required. The repository's name. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/repositories/\[^/\]+$.

commitSha - Optional. The commit SHA for the commit to read from. If unset, the file will be read from HEAD.

path - Required. Full file path to read including filename, from repository root.

$fields - Selector specifying which fields to include in a partial response.

Completes with a ReadRepositoryFileResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<ReadRepositoryFileResponse> readFile(
  core.String name, {
  core.String? commitSha,
  core.String? path,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    'commitSha': ?commitSha == null ? null : [commitSha],
    'path': ?path == null ? null : [path],
    'fields': ?$fields == null ? null : [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$name') + ':readFile';

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return ReadRepositoryFileResponse.fromJson(
    response_ as core.Map<core.String, core.dynamic>,
  );
}