langchain_community.utilities.gitlab.GitLabAPIWrapper

class langchain_community.utilities.gitlab.GitLabAPIWrapper[source]

Bases: BaseModel

Wrapper for GitLab API.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param gitlab_base_branch: Optional[str] = None

The base branch in the GitLab repository, used for comparisons. Usually ‘main’ or ‘master’. Defaults to ‘main’.

param gitlab_branch: Optional[str] = None

The specific branch in the GitLab repository where the bot will make its commits. Defaults to ‘main’.

param gitlab_personal_access_token: Optional[str] = None

Personal access token for the GitLab service, used for authentication.

param gitlab_repository: Optional[str] = None

The name of the GitLab repository, in the form {username}/{repo-name}.

comment_on_issue(comment_query: str) str[source]

Adds a comment to a gitlab issue Parameters:

comment_query(str): a string which contains the issue number, two newlines, and the comment. for example: “1

Working on it now”

adds the comment “working on it now” to issue 1

Returns:

str: A success or failure message

Parameters

comment_query (str) –

Return type

str

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values

Parameters
  • _fields_set (Optional[SetStr]) –

  • values (Any) –

Return type

Model

copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

Parameters
  • include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model

  • exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include

  • update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep (bool) – set to True to make a deep copy of the model

  • self (Model) –

Returns

new model instance

Return type

Model

create_file(file_query: str) str[source]

Creates a new file on the gitlab repo Parameters:

file_query(str): a string which contains the file path and the file contents. The file path is the first line in the string, and the contents are the rest of the string. For example, “hello_world.md

# Hello World!”
Returns:

str: A success or failure message

Parameters

file_query (str) –

Return type

str

create_pull_request(pr_query: str) str[source]

Makes a pull request from the bot’s branch to the base branch Parameters:

pr_query(str): a string which contains the PR title and the PR body. The title is the first line in the string, and the body are the rest of the string. For example, “Updated README

made changes to add info”
Returns:

str: A success or failure message

Parameters

pr_query (str) –

Return type

str

delete_file(file_path: str) str[source]

Deletes a file from the repo :param file_path: Where the file is :type file_path: str

Returns

Success or failure message

Return type

str

Parameters

file_path (str) –

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

Parameters
  • include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –

  • exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –

  • by_alias (bool) –

  • skip_defaults (Optional[bool]) –

  • exclude_unset (bool) –

  • exclude_defaults (bool) –

  • exclude_none (bool) –

Return type

DictStrAny

classmethod from_orm(obj: Any) Model
Parameters

obj (Any) –

Return type

Model

get_issue(issue_number: int) Dict[str, Any][source]

Fetches a specific issue and its first 10 comments :param issue_number: The number for the gitlab issue :type issue_number: int

Returns

A dictionary containing the issue’s title, body, and comments as a string

Return type

dict

Parameters

issue_number (int) –

get_issues() str[source]

Fetches all open issues from the repo

Returns

A plaintext report containing the number of issues and each issue’s title and number.

Return type

str

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

Parameters
  • include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –

  • exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –

  • by_alias (bool) –

  • skip_defaults (Optional[bool]) –

  • exclude_unset (bool) –

  • exclude_defaults (bool) –

  • exclude_none (bool) –

  • encoder (Optional[Callable[[Any], Any]]) –

  • models_as_dict (bool) –

  • dumps_kwargs (Any) –

Return type

unicode

classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model
Parameters
  • path (Union[str, Path]) –

  • content_type (unicode) –

  • encoding (unicode) –

  • proto (Protocol) –

  • allow_pickle (bool) –

Return type

Model

parse_issues(issues: List[Issue]) List[dict][source]

Extracts title and number from each Issue and puts them in a dictionary :param issues: A list of gitlab Issue objects :type issues: List[Issue]

Returns

A dictionary of issue titles and numbers

Return type

List[dict]

Parameters

issues (List[Issue]) –

classmethod parse_obj(obj: Any) Model
Parameters

obj (Any) –

Return type

Model

classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model
Parameters
  • b (Union[str, bytes]) –

  • content_type (unicode) –

  • encoding (unicode) –

  • proto (Protocol) –

  • allow_pickle (bool) –

Return type

Model

read_file(file_path: str) str[source]

Reads a file from the gitlab repo :param file_path: the file path :type file_path: str

Returns

The file decoded as a string

Return type

str

Parameters

file_path (str) –

run(mode: str, query: str) str[source]
Parameters
  • mode (str) –

  • query (str) –

Return type

str

classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') DictStrAny
Parameters
  • by_alias (bool) –

  • ref_template (unicode) –

Return type

DictStrAny

classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) unicode
Parameters
  • by_alias (bool) –

  • ref_template (unicode) –

  • dumps_kwargs (Any) –

Return type

unicode

update_file(file_query: str) str[source]

Updates a file with new content. :param file_query: Contains the file path and the file contents.

The old file contents is wrapped in OLD <<<< and >>>> OLD The new file contents is wrapped in NEW <<<< and >>>> NEW For example: test/hello.txt OLD <<<< Hello Earth! >>>> OLD NEW <<<< Hello Mars! >>>> NEW

Returns

A success or failure message

Parameters

file_query (str) –

Return type

str

classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

Parameters

localns (Any) –

Return type

None

classmethod validate(value: Any) Model
Parameters

value (Any) –

Return type

Model

Examples using GitLabAPIWrapper