Interconnecting with API Explorer and Obtaining Cloud Service API Metadata
Scenario
API Explorer is a one-stop API solution platform provided by Huawei Cloud for developers, which integrates open APIs of Huawei Cloud services and supports quick search, visualized debugging, and help documents, helping developers quickly search for and learn APIs and locate and rectify faults.
By interconnecting with API Explorer, Huawei Cloud Astro Zero can obtain a large amount of API metadata of Huawei Cloud services, and provide connectors for developers to accessing these APIs without developing a connector for each cloud service.
Currently, Huawei Cloud Astro Zero supports APIs for the following cloud services. This section uses NLP as an example to describe how to use Huawei Cloud API Explorer to import connectors.
- Natural Language Processing (NLP)
A cloud service pertained to various enterprises and developers for text analysis and mining. It aims to help users efficiently process text.
- Conversational Bot Service (CBS)
A cloud service developed based on AI technologies for enterprise application scenarios. It involves QABot, SA, CBS Customization (CBSC), and TaskBot. For more information, see Conversational Bot Service.
- Face Recognition Service (FRS)
An intelligent service that uses computers to process, analyze, and understand facial images based on human facial features. For more information, see Face Recognition Service.
- Content Moderation
Adopts image, text, and video detection technologies that detect pornography, advertisements, or material related to terrorism, and sensitive political information. This reduces potential business risks. For more information, see Content Moderation.
- Optical Character Recognition (OCR)
Provides services through open Application Programming Interfaces (APIs). You can obtain the inference result by accessing and invoking APIs in real time. For more information, see Optical Character Recognition.
- Image Recognition
Uses deep learning technologies to accurately identify objects, scenes, and concepts in images using a pool of visual content tags. For more information, see Image Recognition.
- Image Search
Leverages deep learning and image recognition for feature vectorization and search capabilities customizable to individual services and industries. It makes exact or fuzzy matches of gallery images. For more information, see Image Search.
- Video Ingestion Service (VIS)
Ingests massive volumes of video data in real time. With its impressive data collection, real-time transmission, and powerful video retention capabilities, you can easily build intelligent analysis applications through integration with Huawei Cloud Video Analysis Service (VAS).
- Video Analysis Service (VAS)
Uses AI technologies to perform intelligent analysis of video content. VAS includes a wide array of functions, such as video preprocessing, content moderation, content analysis, editing, search, and video fingerprinting. It delivers the detection, tracking, attribute identification, behavior identification, content moderation, video abstraction, and can tag the objects in videos. VAS efficiently and effectively analyzes your video content.
- Speech Interaction Service (SIS)
Uses APIs to convert speech into text, or text into natural speech in real time. For more information, see Speech Interaction Service.
Prerequisites
- You have registered an account with Huawei Cloud NLP and obtained the project ID in the region of your NLP resources.
Figure 1 Obtaining a project ID
- You have obtained the access key ID (AK) and secret access key (SK). For details, see Obtaining an AK/SK.
Creating a NLP Connector
- Log in to the application designer by referring to Logging In to the Application Designer.
- In the navigation pane, choose Integrations.
- Click Connector Instance under Connector.
- In the navigation pane, choose API Explorer > Natural Language Processing.
- On the right of the page, click + to set the parameters for interconnecting with the NLP connector.
Table 1 New NLP connector parameters Parameter
Description
Name
Name of the connector to be created. The naming requirements are as follows:
- The value cannot exceed 64 characters, including the prefix namespace.
To prevent duplicate data names among different tenants, each tenant must define a unique namespace when first creating an application. A tenant can create only one namespace. After being created, the namespace cannot be modified.
- Start with a letter and can contain only letters, digits, and underscores (_). Do not end with an underscore (_).
Access Key ID
Set this parameter to the value of Access Key Id obtained in Prerequisites.
Secret Access Key
Set this parameter to the value of Secret Access Key obtained in Prerequisites.
Region
Region where the NLP service is located. NLP and Huawei Cloud Astro Zero can be in different regions.
Project ID
Project ID of the current user. Set this parameter to the value obtained in Prerequisites.
Description
Enter the description of the connector.
Value: 1–255 characters.
- The value cannot exceed 64 characters, including the prefix namespace.
- Click Save.
- On the connector details page, click an API in the test section, and click Try it out to simulate API calling.
Take the RunNer API in the NLP fundamentals as an example.
API request parameters:
{ "postNerRequest": { "text": "Book a ticket from city A to city B at 10 a.m. tomorrow.", "lang": "en" } }
Configure request parameters for each API based on the format in the "example model". For details, see the API reference of each service.
If the following information is returned, the API is successfully called.
{ named_entities: [ { len: 3, offset: 7, tag: 't', word: '10 a.m.' }, { len: 2, offset: 10, tag: 'ns', word: 'City A' }, { len: 2, offset: 13, tag: 'ns', word: 'City B' } ] }
Calling a Connector in a Script
In the script, call the created connector to connect to Huawei Cloud NLP.
- Create an empty script by referring to Creating a Blank Script.
- In the script editor, enter the following code.
Take the RunNer API in the NLP fundamentals as an example.
// Here's your code. import * as connector from 'connector'; let client = connector.newClient("NLP","Namespace__TEST"); let req ={ "postNerRequest": { "text": "Book a ticket from city A to city B at 10 a.m. tomorrow.", "lang": "en" } }; let resp = client.invoke("RunNer", req); console.log(resp)
In connector.newClient, NLP is the cloud service name, and Namespace__TEST is the connector name.
- Click
in the upper part of the script editor to save the script.
- Click
in the upper part of the editor page to execute the script.
- The input parameters have been set in 2. You do not need to set them here. Click
in the upper right corner of the test window.
- On the log tab page, the log shows that the data on the NLP is updated.
0628 16:00:52.971|debug|vm[310]>>> Build #AstroZero Core 1.3.6 on amd64 Built on 2021-06-26 20:14:28 Commit #b5759f4 0628 16:00:52.971|debug|vm[310]>>> node: 12 0628 16:00:52.971|debug|vm[310]>>> script: Namespace__NLP001 1.0.1 0628 16:00:52.971|debug|vm[310]>>> locale: zh_CN 0628 16:00:52.971|debug|vm[310]>>> timezone: (GMT+08:00) China Standard Time (Asia/Shanghai) 0628 16:00:57.441|debug|vm[310]>>> { named_entities: [ { len: 3, offset: 7, tag: 't', word: '10 a.m.' }, { len: 2, offset: 10, tag: 'ns', word: 'City A' }, { len: 2, offset: 13, tag: 'ns', word: 'City B' } ] } (Namespace__NLP001.ts:12)
- Click
in the upper part of the script editor to activate the script.
Calling a Connector in a Flow
In the flow, call the created connector to connect to NLP.
- Create a flow by referring to Creating a Blank Flow.
- Set input and output parameters for the flow.
- In the right pane of the flow editing page, click
.
- On the Context panel, click
next to Variable.
- Create the input parameter variable inputrequest and output parameter variable output, and set the variable type to Any, as shown in Figure 2.
- Click
and set the input and output parameters of the flow.
- In the right pane of the flow editing page, click
- On the left of the editor, choose Connector > API Explorer > Enterprise Intelligence. Drag Natural Language Processing into the canvas.
- Click
and set basic information.
Figure 3 Setting basic informationTable 2 Parameters Parameter
Description
Label
Display name of the diagram element.
Name
Unique ID of the diagram element.
Description
Description of the diagram element.
Connector
Name of the connector used by the flow. Select the connector Namespace__TEST created in Creating a NLP Connector.
- Click
and set parameters for calling NLP.
Figure 4 Configure NLP parametersTable 3 Connector parameters Parameter
Description
Action
As an example, select the RunNer API in the NLP basic service here.
Input Parameters
Set the input parameters. Select postNerRequest for Target and drag variable inputrequest to Source.
Output Parameters
Set output parameters. Select result for Source and drag variable output to Target.
- Connect the Start and NLP diagram elements.
Figure 5 Connecting diagram elements
- Click
to save the flow.
- Click
to activate the flow.
- Set input parameters and click the run button.
{ "inputrequest": { "text": "Book a ticket from city A to city B at 10 a.m. tomorrow.", "lang": "en" } }
If the following information is displayed, the connection is successful.
{ "interviewId": "002N000000kw6bnc9CZU", "outputs": { "outputs": { "named_entities": [ { "len": 3, "offset": 7, "tag": "t", "word": "10 a.m." }, { "len": 2, "offset": 10, "tag": "ns", "word": "City A" }, { "len": 2, "offset": 13, "tag": "ns", "word": "City B" } ] } } }
- Click
in the upper part of the flow page to activate the flow.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot