Running action or trigger
    • PDF

    Running action or trigger

    • PDF

    Article Summary

    Available in VPC

    You can run actions or triggers created. You can also set up external link addresses so they can be run remotely if you're using NAVER Cloud Platform's API Gateway.

    Run in console

    The following describes how to run an action (trigger) on the NAVER Cloud Platform console.

    1. From the NAVER Cloud Platform console's Region menu, click and select the region you're using.
    2. From the Platform menu, click and select VPC.
    3. Click the Services > Compute > Cloud Functions menus, in that order.
    4. Click the Action (trigger) menu.
    5. Click an action to run in Packages/actions (trigger).
    6. Click the Basic information tab menu, and then click the [Run] button.
    7. When the Run pop-up window appears, set up the required information.
      • Name: Check the name of the action (trigger) to run.
      • Runtime parameter: Write a parameter to be delivered upon running the action (trigger) and used for the execution of the action (trigger) in the JSON format. Run parameters have a higher priority of application compared to default parameters applied to an action (trigger) or package parameters.
        {
          "name": "Ncloud_2",
          "place": "Cloud Function 2"
        }
        
      • View result only: Click and select whether to see the summary of execution result. (True: View the summarized final execution result only, False: View all results including metadata, final execution result, etc.)
    8. Click the [Run] button.
    9. Check the execution result in Result.
      • Action execution result
        cloudfunctions-run-vpc_01_ko
      • Trigger execution result
        cloudfunctions-run-vpc_02_ko
    10. To copy the result code, click the [Copy] button.
    Note

    If you only see the execution result and the activationId value in Step 9, then the remaining details can be seen in the action (trigger)'s Monitoring tab menu.

    Create external link address

    You can run actions (triggers) remotely if you create external link addresses using NAVER Cloud Platform's API Gateway. However, external link addresses can be created for actions, basic triggers, and GitHub triggers only.

    Caution
    • Additional fees apply when you request subscription to API Gateway. For an introduction on API Gateway and more details about pricing plans, refer to the Service > Application services > API Gateway menu in the NAVER Cloud Platform portal.
    • Be cautious when you delete actions or triggers. If you delete an action (trigger) with an external link address set up, then the API Gateway resource connected to it will also be deleted. If there is a single resource in the API Gateway stage, then the stage will be deleted as well.

    The following describes how to create an external link address.

    1. From the NAVER Cloud Platform console's Region menu, click and select the region you're using.
    2. From the Platform menu, click and select VPC.
    3. Click the Services > Compute > Cloud Functions menus, in that order.
    4. Click the Action (trigger) menu.
    5. Click the action (trigger) to set up the remote execution in Packages/actions (triggers).
    6. Click the Basic information tab menu, and then click the [Create external link address] button.
    7. When the Create external link address pop-up window appears, select a product to use from Select product, and then click the [Next] button.
      • Click Create new and enter information if you'd like to create and select a new product.
    8. Click and select the API to use from Select API, and then click the [Next] button.
      • Click Create new and enter information if you'd like to create and select a new API.
    9. Click and select a stage to deploy from Select stage.
      • Click Create new and enter information if you'd like to create and select a new API.
    10. Click and select whether to use IAM authentication for API security in Authentication.
    11. Click the [Complete] button.
    Note
    • For more details on how to use API Gateway, refer to API Gateway Guide.
    • For action (trigger) connection using API Gateway, two call methods are provided: a private call through IAM authentication provided by API Gateway, and a public call through None. If a private call is required, you can apply the IAM authentication method within API Gateway. For the detailed setting instructions, refer to API Gateway Guide.

    URL configuration

    Actions and triggers contain information for the URLs that can be called. General actions and triggers support the POST request format. However, a web action where the web property is true supports all the REST request types including GET, POST, PUT, DELETE, and OPTION, so a section to specify the type is added to the URL generated through API Gateway. The type value must be explicitly specified. The URL parameters can be appended to the type, in the form of ?key=value.
    The following describes the basic form and configuration of external link addresses created using API Gateway.

    https://{product_id}.apigw.ntruss.com/{api_name}/{stage_name}/{resource_name}/{type+}
    
    • product_id: product ID created using API Gateway
    • api_name: name of the API created using API Gateway
    • stage_name: stage name created and deployed using API Gateway.
    • resource_name: This is the name of the resource created using API Gateway. It's randomly generated to prevent issues occurring from resource overwrite.
    • type+: This is a format to form a response to a call in case of external link address for a web action. The supported types are /json, /http, /svg, /html, /text, etc.
    • Action query string
      • blocking
        • true: Requests synchronous execution. An HTTP response can be received after the action execution is completed, and the action result is delivered as the response body value. If the action execution exceeds 1 minute, then it is switched to the asynchronous call and the HTTP response is delivered immediately.
        • false: Requests asynchronous execution (default). The HTTP response is sent immediately regardless whether the action succeeds or fails. The response body delivered only contains the execution result's unique ID value (activationId).
      • result
        • true: Only the final return value (response.result) for the action (trigger) execution among the execution results is delivered as the HTTP response body.
        • false: This is the default value. The entire execution result is delivered as the HTTP response body.
    Caution

    Only asynchronous execution requests are supported for triggers. The response body won't include the execution result.

    Run in terminal

    You can use cURL to run actions or triggers in a terminal. If you've set the result value to true when running them, then only the summarized final execution result is shown. If you've set it to false, then various metadata related to the execution including the final execution result is shown.

    Action/trigger

    General actions or triggers can be run by entering parameters written in ActionURL and JSON. In such cases, they can only be run with HTTP POST.

    $curl -X POST -d "{parameter to be delivered}"  -H "Content-Type: application/json" "{action_url}?blocking=true&result=true"
    

    The following example is when the ActionURL value is "https://zzz" and the parameter to be delivered is {"info":"qqq"}.

    $curl -X POST -d "{/"info/":/"qqq/"}"  -H "Content-Type: application/json" -H "https://zzz?blocking=true&result=true"
    

    Web action

    Actions with the web property can handle all types of requests provided in the REST format, not just HTTP POST.

    $curl -X GET -d "{parameter to be delivered}"  -H "Content-Type: application/json"  "{action_url}{type+}?blocking=true&result=true"
    

    The following example is when the ActionURL value is "https://zzz" and the parameter to be delivered is {"info":"qqq"}.

    $curl -X GET -d "{/"info/":/"qqq/"}"  -H "Content-Type: application/json" "https://zzz/http?blocking=true&result=true"
    

    Execution result

    You can check and manage the execution results of actions or triggers.

    Monitoring

    The execution results of actions and triggers can be seen on the console's Dashboard, or the monitoring page of the action or trigger executed.

    Note

    You can only view the action execution result in Dashboard.

    Log settings

    You can set up so that logs will be created for actions run. All action containers adds timestamps to information outputted with stdout or stderr, and returns it as the logs field. The following is the Node.js and Python action example code for setting the logs to be created and viewing them.

    • Node.js

      • Log settings

        function main(params) {
            var name = params.name || 'World';
            var place = params.place || 'Naver';
            var payload = 'Hello, ' + name + ' in ' + place + '!';
            console.log(payload)
            console.error(payload)
            return {payload:  payload};
        }
        
      • Get the result and view the log
        cloudfunctions-dashboard-vpc_04_ko

        {
          ...
            "logs": [
                "2018-02-01T06:50:26.134193098Z stdout: Hello, World in Naver!",
                "2018-02-01T06:50:26.134293524Z stderr: Hello, World in Naver!"
            ],
          ...
        }
        
    • Python

      • Log settings
        from __future__ import print_function
        import sys
        
        def main(args):
            name = args.get("name", "stranger")
            greeting = "Hello " + name + "!"
            print (greeting)
            print (greeting, file=sys.stderr)
            return {"greeting": greeting}
        
      • Get the result and view the log
        {
          ...
            "logs": [
                "2018-02-01T07:16:33.847246459Z stderr: Hello stranger!",
                "2018-02-01T07:16:33.847308738Z stdout: Hello stranger!"
            ],
          ...
        }
        

    You can also configure actions of other languages to print a message using stdout or stderr and create logs in a similar way.


    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.