webhook_telegram_bot.plugins.bitbucket.services

This file contains service classes.

Module Contents

Classes

EventProcessor

This base class for event processors.

RepositoryEventProcessor

This class process repository events.

PullRequestEventProcessor

This class process pull request events.

UnknownEventProcessor

This class process unknown events.

BitbucketEventProcessor

This class process json from Bitbucket hook.

class webhook_telegram_bot.plugins.bitbucket.services.EventProcessor

Bases: abc.ABC

This base class for event processors.

entity :str
action :str
json_data :Dict[str, Any]
property actor_display_name(self) Optional[str]

Return display name of event actor.

Returns

display name of event actor or None

property repository_name(self) Optional[str]

Return repository name.

Returns

repository name or None

property repository_href(self) Optional[str]

Return repository href.

Returns

repository href or None

abstract get_template_name_with_context(self) Tuple[str, Dict[str, Any]]

Return template name with render context.

Returns

tuple of template name and render context

class webhook_telegram_bot.plugins.bitbucket.services.RepositoryEventProcessor(entity: str, action: str, json_data: Dict[str, Any])

Bases: EventProcessor

This class process repository events.

property changes(self) Optional[Dict[str, Any]]

Return dict of changes.

Returns

dict of changes or None

property branch_name(self) Optional[str]

Return branch name.

Returns

branch name or None

property branch_href(self) Optional[str]

Return hyperlink to branch.

Returns

branch href or None

property is_created(self) Optional[bool]

Return True if branch was created.

Returns

True if branch was created, False if not, None if failed to get

property is_closed(self) Optional[bool]

Return True if branch was closed.

Returns

True if branch was closed, False if not, None if failed to get

property pipeline_title(self) Optional[str]

Return pipeline title.

Returns

pipeline title or None

property pipeline_state(self) Optional[str]

Return pipeline state.

Returns

pipeline state: ‘STARTED’, ‘FINISHED’, ‘FAILED’ or None

property pipeline_href(self) Optional[str]

Return href to pipeline.

Returns

href to pipeline or None

property number_of_commits(self) Tuple[int, bool]

Return a tuple of number of commits and bool determines whether there were more than 5 commits.

Returns

tuple of number of commits and bool determines whether there were more than 5 commits.

get_commit_description(self, commit: Dict[str, Any]) Optional[str]

Return commit description.

Parameters

commit – dictionary of information about commit

Returns

commit description

get_commit_href(self, commit: Dict[str, Any]) Optional[str]

Return hyperlink to comment.

Parameters

commit – dictionary of information about commit

Returns

commit href

get_context(self) Dict[str, Any]

Return render context.

Returns

render context

get_template_name_with_context(self) Tuple[str, Dict[str, Any]]

Return template name with render context.

Returns

tuple of template name with render context.

class webhook_telegram_bot.plugins.bitbucket.services.PullRequestEventProcessor(entity: str, action: str, json_data: Dict[str, Any])

Bases: EventProcessor

This class process pull request events.

property pull_request_id(self) Optional[int]

Return pull request id.

Returns

pull request id or None

property pull_request_title(self) Optional[str]

Return pull request title.

Returns

pull request title or None

property pull_request_href(self) Optional[str]

Return hyperlink to pull request.

Returns

href to pull request or None

get_context(self) Dict[str, Any]

Return render context.

Returns

render context

get_template_name_with_context(self) Tuple[str, Dict[str, Any]]

Return template name with render context.

Returns

tuple of template name and render context.

class webhook_telegram_bot.plugins.bitbucket.services.UnknownEventProcessor(entity: str, action: str, json_data: Dict[str, Any])

Bases: EventProcessor

This class process unknown events.

get_template_name_with_context(self) Tuple[str, Dict[str, Any]]

Return template name with render context.

Returns

tuple of template name and render context

class webhook_telegram_bot.plugins.bitbucket.services.BitbucketEventProcessor(event_key: str, json_data: Dict[str, Any])

This class process json from Bitbucket hook.

_is_repository_event(self) bool

Return True if event come from repository.

Returns

True if event come from repository.

_is_pull_request_event(self) bool

Return True if event come from pull request.

Returns

True if event come from pull request.

get_event_processor(self) Union[UnknownEventProcessor, RepositoryEventProcessor, PullRequestEventProcessor]

Return event processor instance.

Returns

event processor instance.

get_template_name_with_context(self) Tuple[str, Dict[str, Any]]

Return template name with render context.

Returns

tuple of template name and render context.