Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex API Gateway
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Creating API gateways
    • Updating API gateways and their specifications
    • Connecting a domain
    • Deleting API gateways
    • Monitoring
    • Viewing the execution log
  • Tutorials
    • All practical guidelines
    • Deploying a web application using the Java Servlet API
    • Developing a skill for Alice and a website with authorization
    • Developing a Slack bot
    • Developing a Telegram bot
    • Developing user integration
    • Developing CRUD APIs for movie services
    • Communicating with an API gateway using the WebSocket protocol
  • Concepts
    • Relationships between service resources
    • Specification extensions
      • Overview
      • Static response
      • Invoking a function
      • Integration with Serverless Containers
      • Access via HTTP
      • Integration with Object Storage
      • Integration with DataSphere
      • Integration with Data Streams
      • Integration with Message Queue
      • Integration with YDB
      • Greedy parameters
      • Generalized HTTP method
      • Authorization using a function
      • WebSocket protocol support
    • Quotas and limits
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • ApiGatewayService
      • OperationService
    • REST
      • Overview
      • ApiGateway
        • Overview
        • addDomain
        • create
        • delete
        • get
        • getOpenapiSpec
        • list
        • listAccessBindings
        • listOperations
        • removeDomain
        • setAccessBindings
        • update
        • updateAccessBindings
  • Websocket API reference
    • Authentication in the API
    • gRPC
      • Overview
      • ConnectionService
    • REST
      • Overview
      • Connection
        • Overview
        • disconnect
        • get
        • send
  • Questions and answers
  1. Concepts
  2. Specification extensions
  3. Invoking a function

x-yc-apigateway-integration:cloud_functions extension

Written by
Yandex Cloud
  • Supported parameters
  • Extension specification
  • The request structure v0.1
  • The request structure v1.0

The x-yc-apigateway-integration:cloud-functions extension invokes the specified function. As its input, the function accepts the HTTP request data and values of the parameters listed in the specification. As the output, it returns the result of function execution to the client. The request data is transmitted in the same format as that of the current version of the HTTP integration when invoking the function with the integration=raw request string parameter that is most compatible with the AWS API Gateway format. The values of parameters listed in the specification are passed to the params field of the data parameter.

Supported parameters

The table below lists the parameters specific to API Gateway API gateways. Read more about other parameters in the OpenAPI Specification 3.0.

Parameter Type Description
function_id string ID of the function.
tag string Optional. Tag of the function version. The default value is $latest.
Parameters are substituted in tag.
service_account_id string ID of the service account used for authorization when accessing the function. If the parameter is omitted, the value of the top-level service_account_id parameter is used. If there is no top-level parameter, the function is invoked without authorization.
payload_format_version string Function call format version. Possible values: 0.1 and 1.0. Default version is 0.1.
context object Optional. Operation context is an arbitrary object in YAML or JSON format. Passed to a function inside a request in the requestContext.apiGateway.operationContext. Context is where parameter substitution takes place.

Extension specification

Example specification:

/example/{ID}:
    get:
      summary: Get ID
      operationId: getID
      tags:
        - example
      parameters:
        - name: ID
          in: path
          description: Return ID
          required: true
          schema:
            type: string
      x-yc-apigateway-integration:
        type: cloud_functions
        function_id: b095c95icnvbuf4v755l
        tag: "$latest"
        service_account_id: ajehfe56hhlsd4n93q1

Function example:

exports.handler= async function (data, context) {
    return {
        'statusCode': 200,
        'isBase64Encoded': false,
        'body': JSON.stringify({
            'petId': data.params.ID
        }),
    }
};

The request structure v0.1

The request JSON structure for version 0.1 replicates the request structure to a function with some additional fields:

{
    "url": <actual request path>,
    "path": <path corresponding to the request in the specification>,
    "httpMethod": <HTTP method name>,
    "headers": <dictionary with string values for HTTP headers>,
    "multiValueHeaders": <dictionary with lists of values of HTTP headers>,
    "queryStringParameters": <dictionary of queryString parameters>,
    "multiValueQueryStringParameters": <dictionary of list of values of queryString parameters>,
    "requestContext": <dictionary with the request context>,
    "body": <body of the request>,
    "isBase64Encoded": <true or false>
    "pathParams": <dictionary of values of the request path parameters>,
    "params": <dictionary of values of the request parameters described in the OpenAPI specification>,
    "multiValueParams": <dictionary with lists of request parameter values described in the OpenAPI specification>
}

The request structure v1.0

Request JSON structure for version 1.0 is compatible with the request format for AWS API Gateway version 1.0 with some additional fields:

{
    "version": <request format version>,
    "resource": <resource corresponding to the request in the specification>,
    "path": <actual request path>,
    "httpMethod": <HTTP method name>,
    "headers": <dictionary with string values of HTTP headers>,
    "multiValueHeaders": <dictionary with lists of values of HTTP headers>,
    "queryStringParameters": <dictionary of queryString parameters>,
    "multiValueQueryStringParameters": <dictionary of lists of values of queryString parameters>,
    "requestContext": <dictionary with the request context>,
    "pathParameters": <dictionary of the request path parameter values>,
    "body": <request body>,
    "isBase64Encoded": <true or false>,
    // additional fields:    
    "parameters": <dictionary of values of the request parameters described in the OpenAPI specification>,
    "multiValueParameters": <dictionary with lists of values of the request parameters described in the OpenAPI specification>,
    "operationId": <The operationId that corresponds to the request in the OpenAPI specification>
}

Was the article helpful?

Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
In this article:
  • Supported parameters
  • Extension specification
  • The request structure v0.1
  • The request structure v1.0