- Print
- PDF
API Workflow scenario
- Print
- PDF
Available in Classic and VPC
This guide explains scenarios for using API Workflow.
Step 1. Create API authentication key
To create workflows using NAVER Cloud Platform's APIs, you need to complete NCP Signature authentication. When authenticating NCP Signature, you need the information of access key ID and secret key of the API authentication key. The following describes how to create an API authentication key.
- Log in to the NAVER Cloud Platform portal.
- Click the My Page > Manage account > Manage authentication key menu.
- Click the [Create new API authentication key] button.
- If you have an authentication key that has been already created, then use that authentication key.
- Check the access key ID and secret key of the created API authentication key.
- Create the API authentication key only if you're using NAVER Cloud Platform's API.
- For details about creating API authentication key, refer to Create API authentication key.
- For details about NCP Signature registration, refer to Register NCP Signature.
Step 2. Register API
You can register a new API by registering API's name, method, URL, and request parameters. For APIs provided by NAVER Cloud Platform, you can automatically create the signature for authentication through the access key and secret key registered in API Workflow by selecting NCP Signature as the authentication method. This guide's descriptions are based on registering Search available region list API.
From the NAVER Cloud Platform console, click the Services > Management & Governance > API Workflow menus, in that order.
From the API template menu, click the [Register API template] button.
Enter "Check billing amount" for the name of the API to register.
Select the method, and then enter the URL.
- Method: Select "GET."
- URL: Enter "https://billingapi.apigw.ntruss.com/billing/v1/cost/getDemandCostList."
Add "expense" to Tag.
Select NCP Signature for Authority.
- If the authentication information does not exist, then the NCP Signature registration window appears. Enter the API authentication key information from Step 1.
Enter the Parameters information of the API to call in the Request field, and then click the [Add] button.
Key Description Type Default value Required startMonth Search start month (yyyymm) Query 202204 Enabled endMonth Search end month (yyyymm) Query 202204 Enabled responseFormatType response type (JSON/XML) Query JSON Enabled NoteSet the response type as JSON since API Workflow is able to perform internal searches on responses in the JSON format by default. The start and end months can be set arbitrarily.
Click the [TEST] button in the URL field, and check if the value is retrieved properly.
Click the [Save] button.
For more information on how to register APIs, refer to Register and manage API templates.
Step 3. Create workflow
You can create workflows using APIs registered in the API template. You can also create a workflow that combines multiple workflows.
The following describes how to create a workflow using a registered API.
- From the NAVER Cloud Platform console, click the Services > Management & Governance > API Workflow > Workflow menus, in that order.
- Click the [Create workflow] button.
- Enter the name of the workflow to create.
- In the Workflow diagram of the Workflow tab, click [+] > API.
- Click the [Import] button of API template, select the "Check billing amount" API from the API template list, and then click the [OK] button.
- Click [+] > Set properties under API entity.
- Property refers to a variable that can save a specific value required for the execution of the workflow.
- Click [+Add] in the [Property] tab and create "totalRow" of Integer type to save the number of the billed amount list.
- Save the property information, and then click the [Add] button.
- Property: ${totalRow}
- Entity: API-1, response, body
- Key: getDemandCostListResponse.totalRows
NoteIt means to save the getDemandCostListResponse.totalRows value in the body of the response from the API-1 entity, to the totalRow property. Only JSON body can access internal objects in the form of key1.key2.
- Click [+] > if under the entity created above, and then add an If conditional statement.
- Operand 1st: ${totalRow}
- Comparison: >(Greater than)
- Operand 2nd: manual input, 0
NoteIt is a conditional statement that can check whether the totalRow of the value received as a response from the API-1 entity is greater than 0.
- Click the [+] > Set properties button under the If entity.Note
If SetProperties is located under If, then it means to execute the lower entity when the If conditional statement is true.
- Click the [+Add] button in the [Property] tab and add useAmount of Integer type, and requestId of String type.
- useAmount: Saves billed amount.
- requestId: Saves request ID.
- Set the property information.
Property Entity Key useAmount API-1, response, body getDemandCostListResponse.demandCostList.useAmount requestId API-1, response, body etDemandCostListResponse.requestId - Click Finish entity, and then enter the following in the body.
{ "useAmount" : ${useAmount}, "requestId":"${requestId}" }
Note- The header and body configured in Finish entity are used to store the final result value. When the workflow's endpoint is called, it returns the header and body of that Finish entity.
- If you enter the value of properties in the form of ${propertyKey}, then it is substituted with the properties' value.
- To check if the configured workflow operates normally, click the [Run test] button.
- Check if the billed amount and requestId information is included in Finish.
- If an error occurs, then you can click the entity to check its detailed error message.
- Click the [Create workflow] button.
For more information on how to register workflows, refer to Register and manage workflows.
Step 4. Scheduling
The workflow configured by the user can be executed automatically according to the desired interval. The following describes how to set a workflow to be executed every day at 10:30 AM.
- From the NAVER Cloud Platform console, click the Services > Management & Governance > API Workflow > Workflow menus, in that order.
- Select the workflow, and then click the [Schedule] button.
- When the Set schedule window appears, set the start/end period.
- Enter "0 30 10 * * ?" in the Cron expression input area.
- Enter the request information.
- Click the [Apply] button.
For more information about scheduling, refer to Set automatic execution schedule.