An instruction issuing method based on an API controller
By registering instruction sets through the API controller and performing JSON model pre-parsing and validation, the problems of poor compatibility and high error rate in existing technologies are solved. This enables a fast and reliable instruction issuance and rollback mechanism, supports multiple protocols, and simplifies the operation process.
Patent Information
- Application Number
- CN202210620653.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-02
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2042-06-02
AI Technical Summary
Existing command issuance technology suffers from poor compatibility, high error rate, lack of rollback capability, and cumbersome operation, making it impossible to activate specific business models with a single click.
The API controller registers instruction sets to perform JSON model pre-parsing and pre-validation, and triggers a rollback mechanism in case of exceptions, supporting parallel operation of multiple protocols.
It improved the compatibility of command issuance, reduced the error rate, reduced the number of manual rollbacks, and enabled quick one-click activation of specific business models.
Smart Images

Figure CN114968360B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and in particular to a method for issuing instructions based on an API controller. Background Technology
[0002] Existing command delivery solutions primarily rely on SDK integration, where the client assembles the command content and sends commands to the device via SSH, TELNET, or other traditional command-line interface (CLI). This approach suffers from poor compatibility, varying between vendors, and lacks transaction support. Failures in configuration delivery cannot be rolled back, resulting in a high error rate. Furthermore, it doesn't allow for one-click activation for specific business models, making it cumbersome to use. Summary of the Invention
[0003] The purpose of this invention is to provide a command issuance method based on an API controller to address the shortcomings of existing technologies. By registering the command set under the business model with APIs, and pre-parsing and pre-validating the JSON model during API execution, the error rate is effectively reduced. Furthermore, for each exception captured during API execution, a corresponding rollback mechanism command set can be triggered.
[0004] Firstly, a method for issuing commands based on an API controller is provided, the method including:
[0005] The client sends an HTTP request to the API controller, which includes the address of the registered API and the input model, wherein the API is a RESTful API;
[0006] The API controller locates the corresponding API based on the API's address and distributes the API and the input model to the protocol adapter.
[0007] The protocol adapter first calls the model validator to validate the input model according to the model validation scheme bound in the API, and then distributes the input model to the model parser executor;
[0008] The model parser executor parses the input model, assembles the instruction set or message according to the instruction set scheme or message scheme bound in the API, and sends the entire instruction set or message to the specific device or agent at once to generate a response code;
[0009] The model parser executor calls the rollback executor to parse the response code. Based on the parsing result, it returns the corresponding successful delivery information or extracts the rollback instruction set according to the rollback scheme bound in the API to perform the corresponding rollback delivery operation.
[0010] In one possible implementation, the registered API further includes:
[0011] Create a new API in the API controller's management interface and set the API's basic information, inputs, and outputs;
[0012] Add a model validation scheme to the model validater interface for the API to select and bind to;
[0013] Configure the instruction set scheme or message scheme in the interface of the model parser executor for the API to select and bind to;
[0014] Add a rollback scheme to the rollback executor interface for the API to select and bind to;
[0015] Save the API to the API controller and register it.
[0016] Furthermore, the model verification scheme, the instruction set scheme or message scheme, and the rollback scheme can all be customized.
[0017] In one possible implementation, the input model is in JSON format.
[0018] In one possible implementation, the protocol used by the model parser executor in issuing the entire set of instructions or messages is any one of SSH, TELNET, NETCONF, and RESTCONF.
[0019] In a second aspect, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to implement the method of the first aspect.
[0020] This invention registers the API as a RESTful API, providing unified HTTP delivery capabilities. It supports model validation and error code verification during the API command delivery process, and allows for customization of model parsing logic and rollback schemes for error scenarios. This effectively solves the compatibility issues of existing technologies, achieving compatibility with multiple protocols. While reducing the error rate, the added rollback mechanism effectively reduces the number of manual rollbacks after errors in command delivery. Furthermore, it enables one-click activation for specific business models, saving business activation and error correction time. Attached Figure Description
[0021] Figure 1 This is a flowchart of an instruction issuance method based on an API controller disclosed in an embodiment of the present invention;
[0022] Figure 2 This is a system architecture diagram of the instruction issuance method based on an API controller disclosed in an embodiment of the present invention. Detailed Implementation
[0023] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0024] Figure 1 This is a flowchart of an instruction issuance method based on an API controller disclosed in an embodiment of the present invention.
[0025] In step S101, the client sends an HTTP request to the API controller, the request containing the address of the registered API and the input model, wherein the API is a RESTful API. Optionally, the input model is in JSON format.
[0026] Specifically, the steps for registering an API include: creating a new API in the API controller's management interface, setting the API's basic information and inputs / outputs; adding a model validation scheme in the model validator interface for the API to choose and bind to; configuring an instruction set scheme or message scheme in the model parser executor interface for the API to choose and bind to; adding a rollback scheme in the rollback executor interface for the API to choose and bind to; and saving the API to the API controller and registering it. The model validation scheme, instruction set scheme or message scheme, and rollback scheme can all be customized.
[0027] In step S102, the API controller locates the corresponding API based on the API's address and distributes the API and input model to the protocol adapter;
[0028] In step S103, the protocol adapter first calls the model validator to verify the input model according to the model verification scheme bound in the API. If the model is correct, the process jumps to step S104; if the model is incorrect, an error message is thrown directly and the subsequent process is terminated.
[0029] In step S104, the input model is distributed to the model parser executor.
[0030] In step S105, the model parser executor parses the input model, assembles the instruction set or message according to the instruction set scheme or message scheme bound in the API, and sends the entire instruction set or message to the specific device or agent in one go according to the information provided by the protocol adapter, and generates a response code.
[0031] Specifically, the protocol used by the model parser executor in issuing the entire set of instructions or messages is any one of SSH, TELNET, NETCONF, or RESTCONF.
[0032] In step S106, the model parser executor calls the rollback executor to parse the response code. If there is no exception, the process jumps to step S107; if there is an exception, the process jumps to step S108.
[0033] In step S107, the command was successfully issued.
[0034] In step S108, based on the rollback scheme bound in the API, the scheme in the error scheme library is matched, the rollback instruction set is extracted and the rollback is sent out, and the model parser executor responds to the client layer by layer.
[0035] Figure 2 This is a system architecture diagram of the instruction issuance method based on an API controller disclosed in an embodiment of the present invention. The system mainly includes an API controller 201, a protocol adapter 202, a model validator 204, a model parsing executor 206, a rollback executor 207, and a device or agent 209, as well as auxiliary API configuration library 203, model issuance library 205, and error scheme library 208.
[0036] Among them, API controller 201 is used to provide an API management interface, provide a unified execution entry point for API creation and registration, and save the registered APIs in API configuration library 203.
[0037] Protocol adapter 202 is used to receive APIs and input models distributed from API controller 201. It first sends the input model to model validator 204 for verification. If the verification is correct, it then matches the protocol and distributes it to model parser executor 206.
[0038] The model validator 204 is used to provide model validation configuration binding for the API controller 201 and to validate the input model requested by the protocol adapter 202. It also performs model writing and reading with the model distribution library 205.
[0039] The model parser executor 206 is used to perform actual conversion of the model from the protocol adapter 202 and send instruction sets or messages to the device or agent 209.
[0040] Rollback executor 207 is used to provide error scheme binding for API controller 201 to API, and to execute rollback schemes for response codes of model parser executor 206. The rollback schemes used are from error scheme library 208.
[0041] Device or agent 209 is used to receive the issued instruction set or message.
[0042] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for issuing instructions based on an API controller, characterized in that, The method includes: The client sends an HTTP request to the API controller, which includes the address of the registered API and the input model, wherein the API is a RESTful API; The API controller locates the corresponding API based on the API's address and distributes the API and the input model to the protocol adapter. The protocol adapter first calls the model validator to validate the input model according to the model validation scheme bound in the API, and then distributes the input model to the model parser executor; The model parser executor parses the input model, assembles the instruction set or message according to the instruction set scheme or message scheme bound in the API, and sends the entire instruction set or message to the specific device or agent at once, generating a response code; wherein, the protocol used by the model parser executor in sending the entire instruction set or message is any one of SSH, TELNET, NETCONF, and RESTCONF; The model parser executor calls the rollback executor to parse the response code. Based on the parsing result, it returns the corresponding successful delivery information or matches the scheme in the error scheme library according to the rollback scheme bound in the API, extracts the rollback instruction set, and performs the corresponding rollback delivery operation.
2. The method according to claim 1, characterized in that, The registered APIs also include: Create a new API in the API controller's management interface and set the API's basic information, inputs, and outputs; Add a model validation scheme to the model validater interface for the API to select and bind to; Configure the instruction set scheme or message scheme in the interface of the model parser executor for the API to select and bind to; Add a rollback scheme to the rollback executor interface for the API to select and bind to; Save the API to the API controller and register it.
3. The method according to claim 2, characterized in that, The model verification scheme, the instruction set scheme or message scheme, and the rollback scheme can all be customized.
4. The method according to claim 1, characterized in that, The input model is in JSON format.
5. A computing device comprising a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method of any one of claims 1-4.