fake-api-server.ci.surveillance.runner¶
This module implements the monitoring and management of a Fake API Server's
GitHub repository (means the fake server configuration which be built by
PyFake-API-Server). The module provides a class called FakeApiServerSurveillance
which handles the surveillance of the API documentation configuration. It
provides methods which could be customized by yourself for monitoring the
repository for changes in the API documentation configuration, comparing
the current configuration with the latest configuration, and creating pull
requests when changes are detected.
The main functionality is provided by the FakeApiServerSurveillance
class,
which automates the process of tracking changes in API documentation to
keep the fake server repository up-to-date.
FakeApiServerSurveillance()
¶
Manages the surveillance of a Fake API Server's GitHub repository, monitoring and handling changes in its API documentation.
This class is designed to monitor the GitHub repository of a Fake API Server for changes in the API documentation configuration. It interacts with various components like Git operations, GitHub operations, and API documentations, ensuring the configurations are up-to-date and initiating necessary processes such as creating pull requests when changes are detected. It also handles situations where no changes are present or configurations are missing. This class encapsulates the workflow required for this monitoring and management.
ATTRIBUTE | DESCRIPTION |
---|---|
subcmd_pull_component |
Represents the configuration saving component for handling API documentation updates.
|
git_operation |
Encapsulates git-related operations such as versioning.
|
github_operation |
Handles interactions with GitHub, such as creating pull requests or repository-level actions.
TYPE:
|
Source code in fake_api_server_plugin/ci/surveillance/runner.py
_compare_with_current_config(surveillance_config, new_api_doc_config)
¶
Determines if there are any changes in the new API documentation configuration compared to the current surveillance configuration. This function compares the API documentation configurations stored within the specified configurations and checks whether API keys exist in both configurations and if their data matches.
PARAMETER | DESCRIPTION |
---|---|
surveillance_config
|
SurveillanceConfig object containing the current surveillance configuration, which includes Fake-API-Server configurations and settings.
TYPE:
|
new_api_doc_config
|
FakeAPIConfig object representing the new set of API documentation configurations to be compared with the current surveillance configuration.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tuple[bool, CompareInfo]
|
A boolean value indicating whether there is any change in the API documentation configuration. |
Source code in fake_api_server_plugin/ci/surveillance/runner.py
_deserialize_action_inputs(action_inputs)
¶
Deserializes the provided action_inputs mapping into an ActionInput object.
PARAMETER | DESCRIPTION |
---|---|
action_inputs
|
The dictionary-like mapping containing the input data for an action that needs to be deserialized.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ActionInput
|
The deserialized ActionInput object constructed based on the provided action_inputs mapping. |
Source code in fake_api_server_plugin/ci/surveillance/runner.py
_deserialize_surveillance_config(action_input)
¶
Deserializes the surveillance configuration from the given action input.
This method extracts and converts the surveillance configuration data
from the provided ActionInput
object. It returns a SurveillanceConfig
object constructed using the configuration data obtained.
PARAMETER | DESCRIPTION |
---|---|
action_input
|
Input object containing the surveillance configuration that needs to be deserialized.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SurveillanceConfig
|
The deserialized surveillance configuration. |
Source code in fake_api_server_plugin/ci/surveillance/runner.py
_get_action_inputs()
¶
Retrieves the action inputs as a mapping from the environment variables.
This method extracts action-related inputs from the current environment
by accessing the os.environ
dictionary. It is primarily used to interface
with a configuration or actions that depend on environment-specific details.
RETURNS | DESCRIPTION |
---|---|
Mapping
|
A mapping object containing the action inputs extracted from the environment variables. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If any expected environment variable is not found. |
TypeError
|
If the returned object is not a valid Mapping. |
Source code in fake_api_server_plugin/ci/surveillance/runner.py
_get_latest_api_doc_config(surveillance_config)
¶
Fetches the latest API documentation configuration from the specified API endpoint.
The method makes a GET request to the API documentation URL provided in the configuration. Upon successful retrieval, it deserializes the received response to construct a configuration object, converts it into a usable API configuration instance, and adjusts the base URL using the pulled subcommand arguments from the fake API server configuration.
PARAMETER | DESCRIPTION |
---|---|
surveillance_config
|
Configuration for surveillance including API documentation URL and fake API server details.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
FakeAPIConfig
|
Fake API configuration derived from the latest API documentation. |
Source code in fake_api_server_plugin/ci/surveillance/runner.py
_notify(surveillance_config)
¶
Notifies the surveillance system based on the provided configuration.
This method is intended to handle the notification logic based on the given surveillance configuration.
🚧 This feature is under checking and development.
Currently, the implementation is pending as this represents a backlog task.
PARAMETER | DESCRIPTION |
---|---|
surveillance_config
|
The configuration object containing details required for the surveillance notification.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
No value is returned as the method is designed to perform an internal operation without producing a direct output. |
Source code in fake_api_server_plugin/ci/surveillance/runner.py
_process_api_change(surveillance_config, new_api_doc_config)
¶
Processes changes in API configuration for the surveillance system. This method updates the new API documentation configuration based on the surveillance configuration, handles versioning, and sends out necessary notifications. It is designed to ensure that changes to API are integrated seamlessly into the system workflow.
PARAMETER | DESCRIPTION |
---|---|
surveillance_config
|
Current surveillance configuration used for managing API data. Expected to include details related to API server and subcommands.
TYPE:
|
new_api_doc_config
|
The new API documentation configuration to be applied.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method does not return any value. |
Source code in fake_api_server_plugin/ci/surveillance/runner.py
_process_no_api_change(surveillance_config)
¶
Processes the given surveillance configuration where no API change is required.
This internal method is responsible for handling surveillance configurations that do not necessitate modifications to the API. The received configuration is processed accordingly to ensure compliance with the required internal protocols.
PARAMETER | DESCRIPTION |
---|---|
surveillance_config
|
The surveillance configuration instance to be processed. It contains all the necessary settings and parameters relevant for system operations.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method does not return any values. |
Source code in fake_api_server_plugin/ci/surveillance/runner.py
_process_versioning(surveillance_config)
¶
Processes version change by creating a pull request if changes are detected.
Identifies changes in repository versioning and initiates the pull request
creation process. Uses the GitOperation
class to determine if changes
occurred and constructs a pull request with the help of GithubOperation
using the repository metadata derived from the GithubActionEnv
.
PARAMETER | DESCRIPTION |
---|---|
surveillance_config
|
Configuration object containing required versioning and pull request information.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in fake_api_server_plugin/ci/surveillance/runner.py
_update_api_doc_config(args, new_api_doc_config)
¶
Updates the API documentation configuration using the provided arguments and configuration.
PARAMETER | DESCRIPTION |
---|---|
args
|
The arguments required to execute the API documentation configuration update by subcommand line pull of Fake-API-Server.
TYPE:
|
new_api_doc_config
|
The new configuration object for the API documentation to be applied.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in fake_api_server_plugin/ci/surveillance/runner.py
monitor()
¶
Monitors a GitHub repository for changes in API documentation configurations. This method checks for updates in the API documentation configuration of a given repository, compares it with the current configuration, and processes the changes if any are detected. If no changes are found, it handles the situation accordingly without additional actions.
RETURNS | DESCRIPTION |
---|---|
None
|
None |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the Action Inputs or Surveillance Configuration deserialization fails during processing. |
RuntimeError
|
If the retrieval or comparison processes encounter unexpected conditions that prevent completion. |
Source code in fake_api_server_plugin/ci/surveillance/runner.py
run()
¶
Executes the main operation to monitor the fake API server.
This function is responsible for initializing the logger configuration and
triggering the monitoring process using the FakeApiServerSurveillance
class.
RETURNS | DESCRIPTION |
---|---|
None
|
None |