Skip to main content

Create

Creates an API gateway in the specified folder.

import {
cloudApi,
decodeMessage,
serviceClients,
Session,
waitForOperation,
} from "@yandex-cloud/nodejs-sdk";

const ApiGateway = cloudApi.serverless.apigateway_apigateway.ApiGateway;
const CreateApiGatewayRequest =
cloudApi.serverless.apigateway_apigateway_service.CreateApiGatewayRequest;
const LogLevel_Level = cloudApi.logging.log_entry.LogLevel_Level;

(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.ApiGatewayServiceClient);

const operation = await client.create(
CreateApiGatewayRequest.fromPartial({
folderId: "folderId",
// name: "name",
// description: "description",
// labels: {"key": "labels"},
// openapiSpec: "openapiSpec",
// connectivity: {
// networkId: "networkId",
// subnetId: ["subnetId"]
// },
// logOptions: {
// disabled: true,
// logGroupId: "logGroupId",
// folderId: "folderId",
// minLevel: LogLevel_Level.TRACE
// },
// variables: {undefined: {
// stringValue: "stringValue",
// intValue: 0,
// doubleValue: 0,
// boolValue: true
// }},
// canary: {
// weight: 0,
// variables: {undefined: {
// stringValue: "stringValue",
// intValue: 0,
// doubleValue: 0,
// boolValue: true
// }}
// },
// executionTimeout: {
// seconds: 0,
// nanos: 0
// }
})
);
const finishedOp = await waitForOperation(operation, session);

if (finishedOp.response) {
const result = decodeMessage<typeof ApiGateway>(finishedOp.response);
console.log(result);
}
})();

CreateApiGatewayRequest

folderId : string

ID of the folder to create an API gateway in.

To get a folder ID make a yandex.cloud.resourcemanager.v1.FolderService.List request.

name : string

Name of the API gateway. The name must be unique within the folder.

description : string

Description of the API gateway.

labels : string

Resource labels as key:value pairs.

One of spec

OpenAPI specification of API gateway.

  • openapiSpec : string

    The text of specification, JSON or YAML.

connectivity : Connectivity

Gateway connectivity. If specified the gateway will be attached to specified network/subnet(s).

logOptions : LogOptions

Options for logging from the API gateway.

variables : VariableInput

Values of variables defined in the specification.

canary : Canary

Canary release of the gateway.

executionTimeout : google.protobuf.Duration

Timeout for gateway call execution

Connectivity

Gateway connectivity specification.

networkId : string

Network the gateway will have access to. It's essential to specify network with subnets in all availability zones.

subnetId : string

Complete list of subnets (from the same network) the gateway can be attached to. It's essential to specify at least one subnet for each availability zones.

LogOptions

disabled : bool

Is logging from API gateway disabled.

One of destination

Log entries destination.

  • logGroupId : string

    Entry should be written to log group resolved by ID.

  • folderId : string

    Entry should be written to default log group for specified folder.

minLevel : yandex.cloud.logging.v1.LogLevel.Level

Minimum log entry level.

See LogLevel.Level for details.

VariableInput

One of variableValue

Variable value that can has only primitive type

  • stringValue : string
  • intValue : int64
  • doubleValue : double
  • boolValue : bool

Canary

weight : int64

It describes percentage of requests, which will be processed by canary.

variables : VariableInput

Values specification variables, associated with canary.

Operation

An Operation resource. For more information, see Operation.

id : string

ID of the operation.

description : string

Description of the operation. 0-256 characters long.

createdAt : google.protobuf.Timestamp

Creation timestamp.

createdBy : string

ID of the user or service account who initiated the operation.

modifiedAt : google.protobuf.Timestamp

The time when the Operation resource was last modified.

done : bool

If the value is false, it means the operation is still in progress. If true, the operation is completed, and either error or response is available.

metadata : google.protobuf.Any

Service-specific metadata associated with the operation. It typically contains the ID of the target resource that the operation is performed on. Any method that returns a long-running operation should document the metadata type, if any.

One of result

The operation result. If done == false and there was no failure detected, neither error nor response is set. If done == false and there was a failure detected, error is set. If done == true, exactly one of error or response is set.

  • error : google.rpc.Status

    The error result of the operation in case of failure or cancellation.

  • response : google.protobuf.Any
    The normal response of the operation in case of success.

    If the original method returns no data on success, such as Delete, the response is google.protobuf.Empty. If the original method is the standard Create/Update, the response should be the target resource of the operation. Any method that returns a long-running operation should document the response type, if any.