diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/api-usage.rst | 8 | ||||
-rw-r--r-- | docs/cli-usage.rst | 6 | ||||
-rw-r--r-- | docs/graphql-api-usage.rst | 55 | ||||
-rw-r--r-- | docs/index.rst | 1 |
4 files changed, 63 insertions, 7 deletions
diff --git a/docs/api-usage.rst b/docs/api-usage.rst index 06b9058..6822fe0 100644 --- a/docs/api-usage.rst +++ b/docs/api-usage.rst @@ -1,8 +1,8 @@ -############################ -Getting started with the API -############################ +################## +Using the REST API +################## -python-gitlab only supports GitLab API v4. +python-gitlab currently only supports v4 of the GitLab REST API. ``gitlab.Gitlab`` class ======================= diff --git a/docs/cli-usage.rst b/docs/cli-usage.rst index c728221..0b8abb5 100644 --- a/docs/cli-usage.rst +++ b/docs/cli-usage.rst @@ -1,6 +1,6 @@ -############################ -Getting started with the CLI -############################ +############# +Using the CLI +############# ``python-gitlab`` provides a :command:`gitlab` command-line tool to interact with GitLab servers. diff --git a/docs/graphql-api-usage.rst b/docs/graphql-api-usage.rst new file mode 100644 index 0000000..caa1cfb --- /dev/null +++ b/docs/graphql-api-usage.rst @@ -0,0 +1,55 @@ +##################### +Using the GraphQL API +##################### + +python-gitlab provides basic support for executing GraphQL queries and mutations. + +.. danger:: + + The GraphQL client is experimental and only provides basic support. + It does not currently support pagination, obey rate limits, + or attempt complex retries. You can use it to build simple queries + + It is currently unstable and its implementation may change. You can expect a more + mature client in one of the upcoming major versions. + +The ``gitlab.GraphQLGitlab`` class +================================== + +As with the REST client, you connect to a GitLab instance by creating a ``gitlab.GraphQLGitlab`` object: + +.. code-block:: python + + import gitlab + + # anonymous read-only access for public resources (GitLab.com) + gl = gitlab.GraphQLGitlab() + + # anonymous read-only access for public resources (self-hosted GitLab instance) + gl = gitlab.GraphQLGitlab('https://gitlab.example.com') + + # private token or personal token authentication (GitLab.com) + gl = gitlab.GraphQLGitlab(private_token='JVNSESs8EwWRx5yDxM5q') + + # private token or personal token authentication (self-hosted GitLab instance) + gl = gitlab.GraphQLGitlab(url='https://gitlab.example.com', private_token='JVNSESs8EwWRx5yDxM5q') + + # oauth token authentication + gl = gitlab.GraphQLGitlab('https://gitlab.example.com', oauth_token='my_long_token_here') + +Sending queries +=============== + +Get the result of a simple query: + +.. code-block:: python + + query = """{ + query { + currentUser { + name + } + } + """ + + result = gl.execute(query) diff --git a/docs/index.rst b/docs/index.rst index ca0c83f..d2f1a31 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -7,6 +7,7 @@ cli-usage api-usage api-usage-advanced + graphql-api-usage cli-examples api-objects api/gitlab |