Assembles the HTTP request structure that is common to all GitLab v4 RESTful API requests to manage files performed by this package.
Usage
file_req(
method,
path,
id_project = funky::config_val("id_project"),
ref = NULL,
body_json = NULL,
base_url = funky::config_val("base_url"),
token = funky::config_val("token"),
max_tries = 3L
)Arguments
- method
character(1)
HTTP request method. One of"GET","CONNECT","DELETE","HEAD","OPTIONS","PATCH","POST","PUT"or"TRACE".- path
character(1)
File path, relative to the repository root.- id_project
integer(1)
GitLab project identifier.- ref
character(1)
Git revision expression matching the desired Git tree object, e.g. a ref name (branch, tag, etc.), a commit identifier, or another symbolic reference like"HEAD~10". Omitted ifNULL, otherwise set as a URL parameter in the API request. Note that the GitLab API doesn't support every type of revision expression.- body_json
list()
Data to include as JSON in the HTTP request body.NULLmeans an empty body.- base_url
character(1)
Base URL to the GitLab v4 RESTful API root.- token
character(1)
GitLab access token used for authentication. IfNULL, the API request is made unauthenticated which results in HTTP 404 Not Found and other errors for non-public resources.- max_tries
integer(1)
Maximum number of request attempts in case of an HTTP error. An integerish scalar. Retries are performed using exponential backoff and jitter, seehttr2::req_retry()for details.
See also
Other functions to manage files on GitLab:
commit_files(),
file_commit_action(),
file_content(),
file_create(),
file_delete(),
file_exists(),
file_full(),
file_meta(),
file_update(),
file_write(),
files_delete()
Examples
gitlab:::file_req(method = "HEAD",
path = "README.md",
id_project = 64767928,
ref = "HEAD")
#> <httr2_request>
#> HEAD https://gitlab.com/api/v4/projects/64767928/repository/files/README.md?ref=HEAD
#> Headers:
#> * PRIVATE-TOKEN: <REDACTED>
#> Body: empty
#> Policies:
#> * retry_max_tries : 3
#> * retry_on_failure : FALSE
#> * retry_failure_threshold: Inf
#> * retry_failure_timeout : 30
#> * retry_realm : "gitlab.com"
#> * error_body : <function>