GitLab action
#774
- Author
- Anonymous
- Created
- May 31, 2023, 5:53 p.m.
- Expires
- Never
- Size
- 826 bytes
- Hits
- 61
- Syntax
- Python
- Private
- ✗ No
class GitLabAction:
"""
GitLab action
in the context of GitLab API client, an "action" encapsulates the necessary
information to change (commit) a file in a repository
three (3) attributes are mandatory:
- action: a verb describing the operation on a file
- file_path: the path of the file within GitLab
- content: a string-encoded version of the file onto which the action is
exectued
"""
def __init__(self, file_path: Union[str, Path], content: str):
self._action = ("update",)
self._file_path = (file_path,)
self._content = content
def to_json(self):
return {
"action": self._action,
"file_path": str(self._file_path),
"content": self._content,
}