rest_api
¶
This base module holds abstractions common to using REST API.
See other modules in rest_api
subpackage for detailed derivatives.
- class cpp_linter.rest_api.RateLimitHeaders(reset: str, remaining: str, retry: str)[source]¶
A collection of HTTP response header keys that describe a REST API’s rate limits. Each parameter corresponds to a instance attribute (see below).
- class cpp_linter.rest_api.RestApiClient(rate_limit_headers: RateLimitHeaders)[source]¶
A class that describes the API used to interact with a git server’s REST API.
- Parameters:¶
- rate_limit_headers: RateLimitHeaders¶
See
RateLimitHeaders
class.
-
api_request(url: str, method: str | None =
None
, data: str | None =None
, headers: dict[str, Any] | None =None
, strict: bool =True
) Response [source]¶ A helper function to streamline handling of HTTP requests’ responses.
- Parameters:¶
- url: str¶
The HTTP request URL.
- method: str | None =
None
¶ The HTTP request method. The default value
None
means “GET” ifdata
isNone
else “POST”- data: str | None =
None
¶ The HTTP request payload data.
- headers: dict[str, Any] | None =
None
¶ The HTTP request headers to use. This can be used to override the default headers used.
- strict: bool =
True
¶ If this is set
True
, then anHTTPError
will be raised when the HTTP request responds with a status code greater than or equal to 400.
- Returns:¶
The HTTP request’s response object.
-
set_exit_code(checks_failed: int, format_checks_failed: int | None =
None
, tidy_checks_failed: int | None =None
)[source]¶ Set the action’s output values and shows them in the log output.
-
make_headers(use_diff: bool =
False
) dict[str, str] [source]¶ Create a
dict
for use in REST API headers.
- get_list_of_changed_files(file_filter: FileFilter, lines_changed_only: int) list[FileObj] [source]¶
Fetch a list of the event’s changed files.
- Parameters:¶
- file_filter: FileFilter¶
A
FileFilter
obj to filter files.- lines_changed_only: int¶
A value that dictates what file changes to focus on.
-
static make_comment(files: list[FileObj], format_checks_failed: int, tidy_checks_failed: int, clang_versions: ClangVersions, len_limit: int | None =
None
) str [source]¶ Make an MarkDown comment from the given advice. Also returns a count of checks failed for each tool (clang-format and clang-tidy)
- Parameters:¶
- files: list[FileObj]¶
A list of objects, each describing a file’s information.
- format_checks_failed: int¶
The amount of clang-format checks that have failed.
- tidy_checks_failed: int¶
The amount of clang-tidy checks that have failed.
- clang_versions: ClangVersions¶
The versions of the clang tools used.
- len_limit: int | None =
None
¶ The length limit of the comment generated.
- Returns:¶
The markdown comment as a
str