-
Notifications
You must be signed in to change notification settings - Fork 669
feat: Extend GraphQL class to support multiple authentication methods… #3177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
timmy61109
wants to merge
20
commits into
python-gitlab:main
Choose a base branch
from
timmy61109:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…n methods and more API options This commit extends the constructor (`__init__` method) of the `GraphQL` class to handle a wider range of interactions with the GitLab API. The main changes include: - **Added support for multiple authentication tokens:** In addition to the original `token`, it now supports `private_token`, `oauth_token`, and `job_token`, allowing users to configure based on different authentication requirements. - **Added HTTP Basic Authentication:** Introduced `http_username` and `http_password` parameters, allowing the use of HTTP Basic Authentication to interact with the API. - **Added API version control:** Introduced the `api_version` parameter, with a default value of `"4"`, allowing users to specify the GitLab API version to use. - **Added pagination control parameters:** Added `per_page`, `pagination`, and `order_by` parameters to provide finer control over the API's pagination behavior and data sorting. - **Added an option to keep the Base URL:** Added the `keep_base_url` parameter, allowing the configured base URL to be retained across multiple API calls. - **Added `**kwargs: Any`:** Allows passing additional keyword arguments, providing greater flexibility. These changes make the `GraphQL` class more powerful and flexible, capable of handling a broader range of GitLab API use cases.
…ration files This commit introduces a new class method from_config to the GraphQL class. This method allows users to create a Gitlab connection object by reading configuration files. Users can specify the ID and paths of the configuration files, and the method will parse the connection information (e.g., URL, tokens, SSL verification, etc.) from the files to create a pre-configured Gitlab object. This feature provides a more convenient and configurable way to manage GitLab connections, especially useful for scenarios requiring connections to multiple GitLab instances or aiming to separate connection configurations from the codebase. Example usage (assuming the configuration file is gitlab.ini): ```python gl = GraphQL.from_config(config_files=['gitlab.ini']) ``` Internally, this method utilizes gitlab.config.GitlabConfigParser to handle the parsing of the configuration files.
…iguration files This commit introduces a new class method from_config to the GraphQL class. This method allows users to create a Gitlab connection object by reading configuration files. Users can specify the ID and paths of the configuration files, and the method will parse the connection information (e.g., URL, tokens, SSL verification, etc.) from the files to create a pre-configured Gitlab object. This feature provides a more convenient and configurable way to manage GitLab connections, especially useful for scenarios requiring connections to multiple GitLab instances or aiming to separate connection configurations from the codebase. Example usage (assuming the configuration file is gitlab.ini): Python gl = GraphQL.from_config(config_files=['gitlab.ini']) Internally, this method utilizes gitlab.config.GitlabConfigParser to handle the parsing of the configuration files.
Upgraded version to allow successful installation of packages into the library, as the previous version was not working.
Added parameters to be compatible with parameters required by from_config.
Added parameters to be compatible with parameters required by from_config.
Added parameters to be compatible with parameters required by from_config.
Adding this feature would directly allow specific conditions to be variables, increasing the flexibility of application. Using variables: https://gql.readthedocs.io/en/stable/usage/variables.html
Add GraphQL.enable_debug
Add AsyncGraphQL.enable_debug
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… and more API options
This commit extends the constructor (
__init__
method) of theGraphQL
class to handle a wider range of interactions with the GitLab API. The main changes include:token
, it now supportsprivate_token
,oauth_token
, andjob_token
, allowing users to configure based on different authentication requirements.http_username
andhttp_password
parameters, allowing the use of HTTP Basic Authentication to interact with the API.api_version
parameter, with a default value of"4"
, allowing users to specify the GitLab API version to use.per_page
,pagination
, andorder_by
parameters to provide finer control over the API's pagination behavior and data sorting.keep_base_url
parameter, allowing the configured base URL to be retained across multiple API calls.**kwargs: Any
: Allows passing additional keyword arguments, providing greater flexibility.These changes make the
GraphQL
class more powerful and flexible, capable of handling a broader range of GitLab API use cases.Changes
Documentation and testing
Please consider whether this PR needs documentation and tests. This is not required, but highly appreciated: