| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,8 @@ | |||
| 1 | - ############################ | ||
| 2 | - Getting started with the API | ||
| 3 | - ############################ | ||
| 1 | + ################## | ||
| 2 | + Using the REST API | ||
| 3 | + ################## | ||
| 4 | 4 | ||
| 5 | - python-gitlab only supports GitLab API v4. | ||
| 5 | + python-gitlab currently only supports v4 of the GitLab REST API. | ||
| 6 | 6 | ||
| 7 | 7 | ``gitlab.Gitlab`` class | |
| 8 | 8 | ======================= | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | - ############################ | ||
| 2 | - Getting started with the CLI | ||
| 3 | - ############################ | ||
| 1 | + ############# | ||
| 2 | + Using the CLI | ||
| 3 | + ############# | ||
| 4 | 4 | ||
| 5 | 5 | ``python-gitlab`` provides a :command:`gitlab` command-line tool to interact | |
| 6 | 6 | with GitLab servers. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,55 @@ | |||
| 1 | + ##################### | ||
| 2 | + Using the GraphQL API | ||
| 3 | + ##################### | ||
| 4 | + | ||
| 5 | + python-gitlab provides basic support for executing GraphQL queries and mutations. | ||
| 6 | + | ||
| 7 | + .. danger:: | ||
| 8 | + | ||
| 9 | + The GraphQL client is experimental and only provides basic support. | ||
| 10 | + It does not currently support pagination, obey rate limits, | ||
| 11 | + or attempt complex retries. You can use it to build simple queries | ||
| 12 | + | ||
| 13 | + It is currently unstable and its implementation may change. You can expect a more | ||
| 14 | + mature client in one of the upcoming major versions. | ||
| 15 | + | ||
| 16 | + The ``gitlab.GraphQLGitlab`` class | ||
| 17 | + ================================== | ||
| 18 | + | ||
| 19 | + As with the REST client, you connect to a GitLab instance by creating a ``gitlab.GraphQLGitlab`` object: | ||
| 20 | + | ||
| 21 | + .. code-block:: python | ||
| 22 | + | ||
| 23 | + import gitlab | ||
| 24 | + | ||
| 25 | + # anonymous read-only access for public resources (GitLab.com) | ||
| 26 | + gl = gitlab.GraphQLGitlab() | ||
| 27 | + | ||
| 28 | + # anonymous read-only access for public resources (self-hosted GitLab instance) | ||
| 29 | + gl = gitlab.GraphQLGitlab('https://gitlab.example.com') | ||
| 30 | + | ||
| 31 | + # private token or personal token authentication (GitLab.com) | ||
| 32 | + gl = gitlab.GraphQLGitlab(private_token='JVNSESs8EwWRx5yDxM5q') | ||
| 33 | + | ||
| 34 | + # private token or personal token authentication (self-hosted GitLab instance) | ||
| 35 | + gl = gitlab.GraphQLGitlab(url='https://gitlab.example.com', private_token='JVNSESs8EwWRx5yDxM5q') | ||
| 36 | + | ||
| 37 | + # oauth token authentication | ||
| 38 | + gl = gitlab.GraphQLGitlab('https://gitlab.example.com', oauth_token='my_long_token_here') | ||
| 39 | + | ||
| 40 | + Sending queries | ||
| 41 | + =============== | ||
| 42 | + | ||
| 43 | + Get the result of a simple query: | ||
| 44 | + | ||
| 45 | + .. code-block:: python | ||
| 46 | + | ||
| 47 | + query = """{ | ||
| 48 | + query { | ||
| 49 | + currentUser { | ||
| 50 | + name | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + """ | ||
| 54 | + | ||
| 55 | + result = gl.execute(query) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ | |||
| 7 | 7 | cli-usage | |
| 8 | 8 | api-usage | |
| 9 | 9 | api-usage-advanced | |
| 10 | + graphql-api-usage | ||
| 10 | 11 | cli-examples | |
| 11 | 12 | api-objects | |
| 12 | 13 | api/gitlab | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,7 @@ | |||
| 29 | 29 | __title__, | |
| 30 | 30 | __version__, | |
| 31 | 31 | ) | |
| 32 | - from gitlab.client import Gitlab, GitlabList # noqa: F401 | ||
| 32 | + from gitlab.client import Gitlab, GitlabList, GraphQLGitlab # noqa: F401 | ||
| 33 | 33 | from gitlab.exceptions import * # noqa: F401,F403 | |
| 34 | 34 | ||
| 35 | 35 | warnings.filterwarnings("default", category=DeprecationWarning, module="^gitlab") | |
| Back | FazBrowse Home | New Git URL |
0 commit comments