Cli/ref/mw gitlab api
mw gitlab api
[edit]Make an authenticated request to GitLab API
Synopsis
[edit]Makes an authenticated HTTP request to the GitLab API and prints the response. The endpoint argument should either be a path of a GitLab API v4 endpoint, or âgraphqlâ to access the GitLab GraphQL API.
If the current directory is a Git directory, the GitLab authenticated host in the current directory will be used otherwise gitlab.com
will be used. Override the GitLab hostname with ââhostnameâ.
Placeholder values :fullpath
or :id
, :user
or :username
, :group
, :namespace
, :repo
, and :branch
in the endpoint argument will get replaced with values from the repository of the current directory.
The default HTTP request method is âGETâ normally and âPOSTâ if any parameters were added. Override the method with ââmethodâ.
Pass one or more ââraw-fieldâ values in âkey=valueâ format to add JSON-encoded string parameters to the POST body.
The ââfieldâ flag behaves like ââraw-fieldâ with magic type conversion based on the format of the value:
- literal values âtrueâ, âfalseâ, ânullâ, and integer numbers get converted to appropriate JSON types;
- placeholder values â:namespaceâ, â:repoâ, and â:branchâ get populated with values from the repository of the current directory;
- if the value starts with â@â, the rest of the value is interpreted as a filename to read the value from. Pass â-â to read from standard input.
For GraphQL requests, all fields other than âqueryâ and âoperationNameâ are interpreted as GraphQL variables.
Raw request body may be passed from the outside via a file specified by ââinputâ. Pass â-â to read from standard input. In this mode, parameters specified via ââfieldâ flags are serialized into URL query parameters.
In ââpaginateâ mode, all pages of results will sequentially be requested until there are no more pages of results. For GraphQL requests, this requires that the original query accepts an â$endCursor: Stringâ variable and that it fetches the âpageInfo{ hasNextPage, endCursor }â set of fields from a collection.
mw gitlab api <endpoint> [flags]
Examples
[edit]$ glab api projects/:fullpath/releases $ glab api projects/gitlab-com%2Fwww-gitlab-com/issues $ glab api issues --paginate $ glab api graphql -f query=' query { project(fullPath: "gitlab-org/gitlab-docs") { name forksCount statistics { wikiSize } issuesEnabled boards { nodes { id name } } } } ' $ glab api graphql --paginate -f query=' query($endCursor: String) { project(fullPath: "gitlab-org/graphql-sandbox") { name issues(first: 2, after: $endCursor) { edges { node { title } } pageInfo { endCursor hasNextPage } } } }'
Options
[edit]-F, --field stringArray Add a parameter of inferred type (changes default HTTP method to "POST") -H, --header stringArray Add an additional HTTP request header --hostname string The GitLab hostname for the request (default is "gitlab.com" or authenticated host in current git directory) -i, --include Include HTTP response headers in the output --input string The file to use as body for the HTTP request -X, --method string The HTTP method for the request (default "GET") --paginate Make additional HTTP requests to fetch all pages of results -f, --raw-field stringArray Add a string parameter --silent Do not print the response body
Options inherited from parent commands
[edit]--help Help for this command --no-interaction Do not ask any interactive questions -v, --verbose count Increase output verbosity. Example: --verbose=2 or -vv
SEE ALSO
[edit]- mw gitlab - Interact with the Wikimedia Gitlab instance