Put Action
    • PDF

    Put Action

    • PDF

    Article summary

    Available in Classic and VPC

    Create or edit a Cloud Functions action.

    Request

    The following describes the request format for the endpoint. The request format is as follows:

    MethodURI
    PUT/packages/{packageName}/actions/{actionName}

    Request headers

    For headers common to all Cloud Functions APIs, see Cloud Functions common headers.

    Request path parameters

    The following describes the parameters.

    FieldTypeRequiredDescription
    packageNameStringRequiredPackage name
    • 1 to 50 characters, including English letters, numbers, and special characters "-" and "_", and it can't start with "-"
    • It can't be duplicated with other resource (package, action, trigger) names
    • Enter the special character "-" for actions that are not part of a package
    actionNameStringRequiredAction name
    • 1 to 50 characters, including English letters, numbers, and special characters "-" and "_", and it can't start with "-"
    • It can't be duplicated with other resource (package, action, trigger) names

    Request query parameters

    The following describes the parameters.

    FieldTypeRequiredDescription
    platformStringOptionalPlatform type
    • vpc (default) | classic
    typeStringOptionalAction type
    • basic (default) | web | sequence | sequence-web
      • basic: general action
      • web: web action
      • sequence: sequence action
      • sequence-web: sequence web action
    • It can't be changed to another type

    Request body

    The following describes the request body.

    Basic/web action

    The following describes the parameters.

    FieldTypeRequiredDescription
    descriptionStringOptionalAction description (byte)
    • 0 - 3000
    parametersObjectOptionalDefault parameters of the action
    • JSON in the form of {"key" : "value"}
    • Priority of applying parameters when running actions
      • 1st priority: runtime parameters passed at runtime
      • 2nd priority: default parameters of connected triggers
      • 3rd priority: default parameters in actions
      • 4th priority: default parameters of included packages
    limits.timeoutIntegerRequiredMaximum action execution time (milliseconds)
    • 500 - 300,000
    • Force terminate the action on timeout
    limits.memoryIntegerRequiredMaximum memory size for the action (MB)
    • 128 | 256 | 512 | 1024
    exec.kindStringRequiredAction runtime
    exec.imageUriStringConditionalUser image path
    • Only applicable for custom image runtimes
    • {registryName}/{imageName}:{tag} format
    • If tag is not entered, the default is latest
    exec.binaryBooleanRequiredWhether the action code file is binary
    • true | false
      • true: Enter the Base64-encoded value from the action code file in exec.code
      • false: Enter the action code in exec.code
    exec.codeStringRequiredAction source code
    • Source code: Enter the code verbatim
    • File attachment: Enter the action code file binary data encoded in Base64
    • Need to escape when typing code directly
    • Java or .NET runtime only allows file binaries
    • Java can only be registered as a compressed *.jar file
    • .NET (dotnet) can only be uploaded as a *.zip file (compressed file)
    exec.mainStringRequiredExecution function
    vpcObject[]RequiredInformation about the VPC to connect
    • Only applicable for the VPC platform
    vpc[].vpcNoIntegerRequiredID of the VPC to connect
    vpc[].subnetNoIntegerRequiredID of subnet to connect
    raw-httpBooleanOptionalWhether to use the HTTP origin
    • Supported only for the web action type
    custom-optionsBooleanOptionalSet the HTTP header options
    • Supported only for the web action type

    Sequence/sequence-web action

    The following describes the parameters.

    FieldTypeRequiredDescription
    descriptionStringOptionalAction description (byte)
    • 0 - 3000
    exec.kindStringRequiredAction type
    • sequence (fixed value)
    exec.componentsString[]RequiredList of actions to connect to the sequence action
    • {packageName}/{actionName} format
    • Run in list order
    • When connecting an action that is not part of a package, enter the special character "-" in packageName

    Request example

    The following is a sample request.

    curl -X PUT 'https://cloudfunctions.apigw.ntruss.com/ncf/api/v2/packages/{packageName}/actions/{actionName}' \
    --header 'Content-Type: application/json' \
    --header 'x-ncp-apigw-timestamp: {Timestamp}' \
    --header 'x-ncp-iam-access-key: {Sub Account Access Key}' \
    --header 'x-ncp-apigw-signature-v2: {API Gateway Signature}'
    -d '<See below>'
    
    {
        "description" : "My action",
        "parameters": {
            "name": "Cloud Functions",
            "place": "NCloud"
        },
        "limits": {
            "timeout": 60000,
            "memory": 128
        },
        "exec": {
            "kind": "nodejs:16",
            "code": "function main(params) { \nlet name = params.name || \"World\";\nlet place = params.place || \"Naver\"; \n  return {payload:  \"abc\"};\n}",
            "binary": false,
            "main": "main"
        },
        "vpc": [
            {
                "vpcNo" : ******,
                "subnetNo" : *****
            }
        ]
    }
    

    Response

    The following describes the response format.

    Response body

    The following describes the response body.

    Common fields

    FieldTypeDescription
    content.nameStringAction name
    content.resourceIdStringAction's resource ID
    content.pathStringAction path
    content.descriptionString-
    content.typeString-

    Basic/web action

    FieldTypeDescription
    content.parametersObjectDefault parameters of the action
    content.raw-httpBooleanWhether to use the HTTP origin
    • Supported only for the web action type
    content.custom-optionsBooleanSet the header options
    • Supported only for the web action type
    content.exec.binaryBooleanWhether the action code is file binary
    content.exec.codeStringAction source code or Base64-encoded code file binary
    content.exec.imageUriStringUser image path
    • It is displayed only if the runtime is custom image
    content.exec.kindStringAction runtime
    content.exec.mainStringExecution function
    content.limits.memoryIntegerSize of memory allocated to the action container
    content.limits.timeoutIntegerMaximum time an action can run
    content.vpcObject[]-
    content.vpc[].vpcNoInteger-
    content.vpc[].subnetNoInteger-

    Sequence/web-sequence action

    FieldTypeDescription
    content.exec.kindStringAction type
    • sequence (fixed value)
    content.exec.componentsString[]List of connected actions

    Response status codes

    The following describes the response status codes.

    HTTP status codeCodeMessagesDescription
    40080300ACTION_INVALID_NAMEInvalid action name
    40080102PACKAGE_PLATFORM_MISMATCHThe platform of the action's parent package can't be changed
    40080302ACTION_PLATFORM_MISMATCHAction's platform can't be changed
    40080303ACTION_INVALID_TYPEInvalid action type
    40080304ACTION_TYPE_MISMATCHAction's type can't be changed
    40080305ACTION_BODY_INVALID_TYPEInvalid request body field type
    40080306ACTION_BODY_MISSING_FIELDMissing required fields in the request body
    40080307ACTION_BODY_INVALID_VALUEInvalid request body field value
    40380002SUB_ACC_NO_PERMISSIONDetailed permission error
    40980011RESOURCE_NAME_CONFLICTDuplicate resource name
    42280308ACTION_COUNT_EXCEEDMaximum number of actions exceeded
    50081311ACTION_NAT_EXCEPTIONSubnet query failed
    50081312NAT_CREATE_FAILSubnet connection failed
    50081313NAT_BEING_CREATEDSubnet being connected
    50081314NAT_RETURN_FAILSubnet being disconnected

    Response example

    The following is a sample example.

    {
        "content": {
            "description": "My action",
            "exec": {
                "binary": false,
                "code": "function main(params) { \nlet name = params.name || \"World\";\nlet place = params.place || \"Naver\"; \n  return {payload:  \"abc\"};\n}",
                "kind": "nodejs:16",
                "main": "main"
            },
            "limits": {
                "memory": 128,
                "timeout": 60000
            },
            "name": "myaction",
            "parameters": {
                "name": "Cloud Functions",
                "place": "NCloud"
            },
            "path": "***QK06kFG8C/mypackage",
            "resourceId": "*****",
            "type": "basic",
            "vpc": [
                {
                    "subnetNo": ******,
                    "vpcNo": *****
                }
            ]
        }
    }
    

    Was this article helpful?

    What's Next
    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.