Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
Create nps plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
fchenebault committed Jun 7, 2024
1 parent 5a5bed7 commit ff40e4b
Show file tree
Hide file tree
Showing 8 changed files with 743 additions and 0 deletions.
Empty file.
4 changes: 4 additions & 0 deletions backend/python/plugins/nps/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

cd "$(dirname "$0")"
poetry install
Empty file.
66 changes: 66 additions & 0 deletions backend/python/plugins/nps/nps/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from typing import Iterable

import pydevlake as dl
from pydevlake.pydevlake.domain_layer.crossdomain import Team
from pydevlake.pydevlake.api import Response

class NPSPluginConnection(dl.Connection):
"""The parameters of your plugin split between those that are required to connect to the datasource
that are grouped in your connection class and those that are used to customize conversion to domain
models that are grouped in your scope config class.
https://github.com/apache/incubator-devlake/blob/main/backend/python/README.md#connection-parameters
"""
# TODO : Add a token
url: str


class NPSPluginScopeConfig(dl.ScopeConfig):
"""A scope config contains the list of domain entities to collect and optionally some parameters
used to customize the conversion of data from the tool layer to the domain layer.
For example, you can define a regex to match issue type from issue name.
https://github.com/apache/incubator-devlake/blob/main/backend/python/README.md#scope-config
"""
# Here we could filter by project
pass


class NPSPluginToolScope(dl.ToolScope):
"""The tool scope type is the top-level entity type of your plugin.
For example, a board, a repository, a project, etc.
A scope is connected to a connection, and all other collected entities are related to a scope.
https://github.com/apache/incubator-devlake/blob/main/backend/python/README.md#tool-scope-type
"""
team_name = str


class NPSPlugin(dl.Plugin):
connection_type = NPSPluginConnection
tool_scope_type = NPSPluginToolScope
scope_config_type = NPSPluginScopeConfig
streams = []

def domain_scopes(self, tool_scope: NPSPluginToolScope) -> Iterable[dl.DomainScope]:
"""The domain_scopes method should return the list of domain scopes that are related to a given tool scope.
Usually, this consists of a single domain scope, but it can be more than one for plugins that collect data from multiple domains."""
yield Team(
name=tool_scope.team_name,
)

def remote_scope_groups(self, connection: NPSPluginConnection) -> Iterable[dl.RemoteScopeGroup]:
yield dl.RemoteScopeGroup(
id="1",
name="team1",
)

def remote_scopes(self, connection, group_id: str) -> Iterable[NPSPluginToolScope]:
# Here we should get the list of teams
yield NPSPluginToolScope(team_name='team1'),

def test_connection(self, connection: NPSPluginConnection) -> dl.TestConnectionResult:
# Fake test connection - Should be implemented
response = Response(status=200, json={})
return dl.TestConnectionResult.from_api_response(response)


if __name__ == '__main__':
NPSPlugin.start()
655 changes: 655 additions & 0 deletions backend/python/plugins/nps/poetry.lock

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions backend/python/plugins/nps/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool.poetry]
name = "nps"
version = "0.1.0"
description = ""
authors = ["Florent Chenebault <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "~3.9"
pydevlake = { path = "../../pydevlake", develop = true }

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
4 changes: 4 additions & 0 deletions backend/python/plugins/nps/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

cd "$(dirname "$0")"
poetry run python nps/main.py "$@"
Empty file.

0 comments on commit ff40e4b

Please sign in to comment.