Basic action
    • PDF

    Basic action

    • PDF

    Article Summary

    Available in Classic

    You can create, edit, and delete basic type actions in NAVER Cloud Platform console's Cloud Functions > Action. For how to run and monitor actions created, see Running action/trigger and Action.

    Create actions

    Create an action. You can connect a trigger to an action when creating it, or add a trigger for connection if there isn't a trigger to connect. You can also create an action that can work without a trigger connection. The following describes how to create an action.

    1. From NAVER Cloud Platform console's Region menu, click and select the Region you're using.
    2. From the Platform menu, click and select Classic.
    3. Click the Services > Compute > Cloud Functions menus, in that order.
    4. Click the Action menu.
    5. Click the [Create action] button.
    6. Click and select a trigger to connect to the action from Select trigger's Trigger type.
      • Create action without setting up trigger: when you want to create an action without a trigger connection
    7. Click and select the trigger to connect from Name, and then click the [Add] button.
      • Create new trigger: when there is no trigger to connect, or you want to create a new trigger for connection. For more information on how to use, see Trigger
    8. When the list of triggers to connect appears, check the information, and then click the [Next] button.
    9. Set up the content of the action to create.
      • Basic information: set up the action type, name, description, and package it belongs to
      • Source code: write the code yourself from the console in a language of your choice or upload a code file
      • Default parameter: write the default parameter code to use for the action
      • Option settings: set up the action's main function name, memory, timeout, and web action
    10. Click the [Create] button.

    Basic information

    Set up basic information required for creating an action. Descriptions of each item in Basic information are as follows:

    • Package: select the package where the action will belong. Click the [Create] button to create a new package and add it
    • Type: select Basic among the action types
      • Basic: run a single action
      • Sequence: connect multiple actions and run them in sequence
    • Name: enter the action's name by combining upper and lowercase letters, numbers, and special characters "_" and "-". However, a hyphen (-) can't be used as the first letter. The name must be unique and not a duplicate of another resource (package, action, trigger) name
      • If the package name is package_name and action name is action_name, the format for the name of the action that belongs to the package: {package_name}/{action_name}
    • Description: enter the description of the action to create
    Caution
    • It's possible to create an action without selecting a package so that it doesn't belong to any package, but it's better to create a package and put the action in the package.
    • To learn how to create a sequence type action, see Sequence.
    • Make your decisions carefully as an action's name and type can't be edited.

    Source code

    You can write an action code in a language of your choice in the console, or upload a code file. If you don't set up a runtime parameter for the execution point when you write the code, a default parameter from package or from triggers or actions connected to it will be used. It doesn't apply only to runtime parameters. If you don't write up a code about additional settings, default values will apply for the related settings. Note that some of them may not be edited after creation, so proceed with caution. The description of each item in source code is as follows:

    • Language: select the language in which the source code is written
    • Type: select the method in which the source code is written
      • Code: write directly on the console
      • File: upload the written source code files by clicking Drop files here or click to upload.
    Caution
    • JAVA codes can't be written directly on the console. They must be compiled and uploaded as a JAR file.
    • .NET codes can only be uploaded as a ZIP file format.

    Composition examples

    These are composition examples of source code by language for an action that receives parameter Params, and returns the Name and Place strings if they exist in Params or returns World and Ncloud if they don't exist. Refer to them when you write your source code.

    Note

    The composition method is fixed for the codes to be uploaded in a ZIP or JAR file. Make sure to see the composition guide when you write them.

    • Node.js

      function main(params) {
          var name = params.name || 'World';
          var place = params.place || 'Ncloud';
          return {payload:  'Hello, ' + name + ' in ' + place + '!'};
      }
      
    • Python 3

      def main(args):
          name = args.get("name", "World")
          place  = args.get("place", "Ncloud")
          return {"payload": "Hello, " + name + " in " + place + "!"}
      
    • Swift 3.1.1

      func main(args: [String:Any]) -> [String:Any] {
          let name = args["name"] ?? "World"
          let place = args["place"] ?? "Ncloud"
          return  [ "payload" : "Hello, \(name) in \(place)"]
      }
      
    • PHP 7

      <?php
      function main(array $args) : array
      {
          $name = $args["name"] ?? "World";
          $place = $args["place"] ?? "Ncloud";
          return ["greeting" => "Hello, $name in $place!"];
      }
      ?>
      
    • Java 8

      import com.google.gson.JsonObject;
      
      public class Hello {
          public static JsonObject main(JsonObject args) {
              String name = "World";
              String place = "Ncloud";
              if (args.has("name"))
                  name = args.getAsJsonPrimitive("name").getAsString();
              if (args.has("place"))
                  place = args.getAsJsonPrimitive("place").getAsString();
      
              JsonObject response = new JsonObject();
              response.addProperty("payload", "Hello, " + name + " in " + place + "!");
              return response;
          }
      }
      

    Default parameter

    You can enter a default parameter which can be applied to actions by default rather than delivering a parameter every time an action is run. An action's default parameter has a higher priority of application than a package parameter, and lower priority of application compared to trigger parameters or runtime parameters which are delivered at the time of running the action. Descriptions of each item in Default parameter are as follows:

    cloudfunctions-basicaction-vpc_03_en

    • Input box: enter in JSON format

    The following is example code of a JSON default parameter.

    {
      "name": "Ncloud",
      "place": "Cloud Functions"
    }
    

    Option settings

    You can set up an action's main function name, memory, or timeout, or set up web actions that provide URLs which can be called without a separate user authentication. For web actions, all requests (GET, POST, PUT, DELETE, and so on) of various types of REST API are supported.
    Descriptions of each item in Option settings are as follows:

    • Main function: enter strings to be used as the action's main function or class name
    • Action memory: select the desired memory size
    • Action timeout: enter the maximum time during which the action may run in ms. When the entered time is exceeded, it will finish and the execution result will be logged as a failure
    • Set web action: select whether to create a web action (True: create, False: do not create)
      • Use HTTP source: select whether to have the HTTP source sent and processed as is as a web action (True: use HTTP source, False: use JSON object)
      • Set header option: select whether the header may be edited within the code (True: it can be edited, False: add the CORS header automatically to the response header)

    Edit actions

    An action's name and type can't be edited, but the rest can. The following describes how to edit them.

    1. From NAVER Cloud Platform console's Region menu, click and select the Region you're using.
    2. From the Platform menu, click and select Classic.
    3. Click the Services > Compute > Cloud Functions menus, in that order.
    4. Click the Action menu.
    5. Click the action to edit in Packages/Actions.
    6. Click the Basic information tab menu and then click the [Edit] button.
    7. Edit the necessary information.
    8. Click the [Save] button.

    Delete action

    You can delete an action. When an action is deleted, the resource and stage information of the external link address connected with the action will also be deleted. In addition, the sequence actions that contain the action to be deleted may also be edited or deleted. Proceed carefully as an action can't be restored once deleted. The following describes how to delete an action.

    1. From NAVER Cloud Platform console's Region menu, click and select the Region you're using.
    2. From the Platform menu, click and select Classic.
    3. Click the Services > Compute > Cloud Functions menus, in that order.
    4. Click the Action menu.
    5. Click the action to delete in Packages/Actions.
    6. Click the Basic information tab menu and then click the [Delete] button.
    7. Click the [Delete] button.

    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.