{"id":26071005,"url":"https://github.com/g4-api/g4-external-python","last_synced_at":"2026-04-11T20:47:45.494Z","repository":{"id":277426976,"uuid":"868156281","full_name":"g4-api/g4-external-python","owner":"g4-api","description":"This repository provides a Flask-based API for managing and invoking plugins. The API dynamically loads plugin manifests and exposes endpoints to retrieve plugin details and invoke them. It's designed for flexibility, allowing different types of plugins to be integrated into the application through a caching mechanism.","archived":false,"fork":false,"pushed_at":"2025-02-13T21:06:42.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-13T22:21:23.368Z","etag":null,"topics":["automation","g4-api","python","rpa","rpa-robots","scraper","scrapping","selenium-python","selenium-webdriver"],"latest_commit_sha":null,"homepage":"https://github.com/g4-api/g4-external-python","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/g4-api.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-05T16:11:04.000Z","updated_at":"2025-02-13T21:06:46.000Z","dependencies_parsed_at":"2025-02-13T22:31:53.931Z","dependency_job_id":null,"html_url":"https://github.com/g4-api/g4-external-python","commit_stats":null,"previous_names":["g4-api/g4-external-python"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g4-api%2Fg4-external-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g4-api%2Fg4-external-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g4-api%2Fg4-external-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g4-api%2Fg4-external-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/g4-api","download_url":"https://codeload.github.com/g4-api/g4-external-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242623582,"owners_count":20159702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","g4-api","python","rpa","rpa-robots","scraper","scrapping","selenium-python","selenium-webdriver"],"created_at":"2025-03-09T00:01:16.175Z","updated_at":"2026-04-11T20:47:40.465Z","avatar_url":"https://github.com/g4-api.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Plugin Repository - Quick Start Guide\n\n## Steps to Implement a New Plugin\n\nTo add a new plugin, you need to create **two** files:\n\n1. A **Plugin Class** under the `plugins/` package (you can organize by creating sub-packages if needed).\n2. A **Manifest** file under the `manifests/` folder (sub-packages are also supported here).\n\n### 1. Create a Plugin Class\n\nCreate a Python class that inherits from `PluginBase` and place it in the `plugins/` package. Here’s an example of how to implement a plugin, including how to retrieve and use the WebDriver for UI automation:\n\n```python\nfrom models.plugin_response_model import PluginResponseModel\nfrom plugins.plugin_base import PluginBase\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.support.ui import WebDriverWait\nfrom selenium.webdriver.support import expected_conditions as EC\n\nclass InvokePythonClick(PluginBase):\n    def __init__(self, setup_model):\n        \"\"\"\n        Initializes the plugin with the setup model, which contains the WebDriver for UI automation.\n\n        Args:\n            setup_model (SetupModel): Contains necessary configurations such as the WebDriver.\n        \"\"\"\n        super().__init__(setup_model)\n\n    def invoke(self, action_request):\n        \"\"\"\n        Executes the plugin's logic, such as performing a click action on a UI element.\n\n        Args:\n            action_request (dict): The action request containing the entity and the rules for locating and clicking the element.\n\n        Returns:\n            PluginResponseModel: The response model after execution.\n        \"\"\"\n        # Extract the element details from the action_request\n        rule = action_request[\"entity\"]\n        locator_type = By.CSS_SELECTOR if rule[\"locator\"] == \"CssSelector\" else By.XPATH\n        locator_value = rule[\"onElement\"]\n\n        # Access the WebDriver from the plugin setup model\n        driver = self.plugin_setup_model.driver\n\n        # Wait for the element to be present and perform a click action\n        element = WebDriverWait(driver, 10).until(\n            EC.presence_of_element_located((locator_type, locator_value))\n        )\n        element.click()\n\n        # Return a PluginResponseModel after the action is performed\n        return PluginResponseModel()\n```\n\n### Important Details:\n- The WebDriver instance for UI automation is accessed through `self.plugin_setup_model.driver`.\n- You can use this WebDriver to perform Selenium-based actions such as locating elements, clicking, and interacting with web elements in the browser.\n\n### 2. Create a Manifest File\n\nCreate a JSON manifest file under the `manifests/` folder. The `key` in the manifest must match the plugin class name, and at least one example must be included.\n\n**Example Manifest:**\n\n```json\n{\n    \"key\": \"InvokePythonClick\",\n    \"aliases\": [\"PythonClick\", \"LeftPythonClick\"],\n    \"author\": {\n        \"name\": \"Your Name\",\n        \"link\": \"https://www.example.com\"\n    },\n    \"categories\": [\"UI\", \"Browser\"],\n    \"description\": [\n        \"### Purpose\",\n        \"This plugin performs click actions on specified web elements.\",\n        \"\",\n        \"### Features\",\n        \"- Supports multiple locator strategies.\",\n        \"- Can handle conditional clicks based on element state.\"\n    ],\n    \"summary\": [\n        \"The `InvokePythonClick` plugin is designed to perform click actions on web elements.\",\n        \"It can be used in automation testing, RPA workflows, or any browser interaction tasks.\"\n    ],\n    \"pluginType\": \"Action\",\n    \"manifestVersion\": 4,\n    \"examples\": [\n        {\n            \"description\": [\n                \"Perform a click action on an element with the ID `submitButton` using a CSS selector.\"\n            ],\n            \"rule\": {\n                \"locator\": \"CssSelector\",\n                \"onElement\": \"#submitButton\",\n                \"pluginName\": \"InvokePythonClick\"\n            }\n        }\n    ]\n}\n```\n\n### 3. G4 Engine Settings\n\nTo use this repository with the G4 engine, add the following settings to the G4 automation request:\n\n```json\n\"settings\": {\n    \"pluginsSettings\": {\n        \"externalRepositories\": [\n            {\n                \"name\": \"MainAPIService\",\n                \"url\": \"http://localhost:9999\",\n                \"version\": 4\n            }\n        ]\n    }\n}\n```\n\n## Key Notes\n\n- **Plugin Class**: The plugin class must inherit from `PluginBase`.\n- **Manifest Key**: The `key` in the manifest must match the plugin class name.\n- **Manifest Example**: The manifest must contain at least one example for it to be valid.\n- **Markdown Support**: The `description` and `summary` fields in the manifest support markdown syntax. Each array element represents a new line.\n- **WebDriver Access**: The WebDriver instance for UI automation is accessed through `self.plugin_setup_model.driver`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg4-api%2Fg4-external-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fg4-api%2Fg4-external-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg4-api%2Fg4-external-python/lists"}