publicación /groups/{groupId}/apps/{appId}/functions

Cree una nueva Función.

Parámetros de path

aplicación/json

Cuerpo Requerido

La función para crear

  • can_evaluate Objeto

    A JSON expression that evaluates to true if the Function is allowed to run in response to an incoming request.

  • Nombre string Requerido

    Un nombre único para la función.

  • privado booleano Requerido

    If true, the function is hidden from client applications. You can still call a private function from JSON expressions and other functions, including incoming webhooks and triggers.

  • Origen string Requerido

    El código fuente convertido en string para la función. El código debe ser un ES6 válido.

  • run_as_system booleano

    Si true, la función se ejecuta con todos los privilegios, omitiendo las reglas en todos los servicios.

  • run_as_user_id string

    ID de cuenta de un usuario de la aplicación. Si se define, los endpoints siempre se ejecutarán con el usuario especificado. No se puede usar con run_as_user_id_script_source.

  • run_as_user_id_script_source string

    The stringified source code for a function that returns an application user's account ID. If defined, endpoints execute the function on every request and run as the user with the ID returned from the function. Cannot be used with run_as_user_id.

Respuestas

  • 201 aplicación/json

    The function was successfully created.

    Ocultar atributos de respuesta Mostrar los atributos de respuesta Objeto
    • _id string

      Unique identifier for the function.

    • Nombre string

      Name for the function specified in the name field of the request.

POST /groups/{groupId}/apps/{appId}/functions
curl \
 --request POST 'https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/functions' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"can_evaluate":{},"name":"string","private":true,"source":"string","run_as_system":true,"run_as_user_id":"string","run_as_user_id_script_source":"string"}'
Solicitar ejemplos
{
  "can_evaluate": {},
  "name": "string",
  "private": true,
  "source": "string",
  "run_as_system": true,
  "run_as_user_id": "string",
  "run_as_user_id_script_source": "string"
}
Ejemplos de respuestas (201)
{
  "_id": "string",
  "name": "string"
}