API Workflow scenario
    • PDF

    API Workflow scenario

    • PDF

    Article Summary

    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.

    1. Log in to the NAVER Cloud Platform portal.
    2. Click the My Page > Manage account > Manage authentication key menu.
    3. Click the [Create new API authentication key] button.
      • If you have an authentication key that has been already created, then use that authentication key.
    4. Check the access key ID and secret key of the created API authentication key.
    Note

    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.

    1. From the NAVER Cloud Platform console, click the Services > Management & Governance > API Workflow menus, in that order.

    2. From the API template menu, click the [Register API template] button.

    3. Enter "Check billing amount" for the name of the API to register.

    4. Select the method, and then enter the URL.

      • Method: Select "GET."
      • URL: Enter "https://billingapi.apigw.ntruss.com/billing/v1/cost/getDemandCostList."
    5. Add "expense" to Tag.

    6. 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.
    7. Enter the Parameters information of the API to call in the Request field, and then click the [Add] button.

      KeyDescriptionTypeDefault valueRequired
      startMonthSearch start month (yyyymm)Query202204Enabled
      endMonthSearch end month (yyyymm)Query202204Enabled
      responseFormatTyperesponse type (JSON/XML)QueryJSONEnabled
      Note

      Set 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.

    8. Click the [TEST] button in the URL field, and check if the value is retrieved properly.

    9. Click the [Save] button.

    Note

    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.

    1. From the NAVER Cloud Platform console, click the Services > Management & Governance > API Workflow > Workflow menus, in that order.
    2. Click the [Create workflow] button.
    3. Enter the name of the workflow to create.
    4. In the Workflow diagram of the Workflow tab, click [+] > API.
    5. Click the [Import] button of API template, select the "Check billing amount" API from the API template list, and then click the [OK] button.
    6. Click [+] > Set properties under API entity.
      • Property refers to a variable that can save a specific value required for the execution of the workflow.
    7. Click [+Add] in the [Property] tab and create "totalRow" of Integer type to save the number of the billed amount list.
    8. Save the property information, and then click the [Add] button.
      • Property: ${totalRow}
      • Entity: API-1, response, body
      • Key: getDemandCostListResponse.totalRows
      Note

      It 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.

    9. 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
      Note

      It 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.

    10. 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.

    11. 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.
    12. Set the property information.
      PropertyEntityKey
      useAmountAPI-1, response, bodygetDemandCostListResponse.demandCostList.useAmount
      requestIdAPI-1, response, bodyetDemandCostListResponse.requestId
    13. 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.
    14. 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.
    15. Click the [Create workflow] button.
    Note

    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.

    1. From the NAVER Cloud Platform console, click the Services > Management & Governance > API Workflow > Workflow menus, in that order.
    2. Select the workflow, and then click the [Schedule] button.
    3. When the Set schedule window appears, set the start/end period.
    4. Enter "0 30 10 * * ?" in the Cron expression input area.
    5. Enter the request information.
    6. Click the [Apply] button.
    Note

    For more information about scheduling, refer to Set automatic execution schedule.


    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.