Skip to main content

Create

Creates a new database.

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

const CreateDatabaseRequest =
cloudApi.mdb.clickhouse_database_service.CreateDatabaseRequest;
const Database = cloudApi.mdb.clickhouse_database.Database;

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

const operation = await client.create(
CreateDatabaseRequest.fromPartial({
clusterId: "clusterId",
databaseSpec: {
name: "name",
},
})
);
const finishedOp = await waitForOperation(operation, session);

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

CreateDatabaseRequest​

folderId : string​
name : string​
description : string​
resourcePresetId : string​
storageConfig : StorageConfig​
scalePolicy : ScalePolicy​
networkId : string​
subnetIds : string​

One of databaseType​

  • zonalDatabase : ZonalDatabase​

    deprecated field

  • regionalDatabase : RegionalDatabase​

    deprecated field

  • dedicatedDatabase : DedicatedDatabase​
  • serverlessDatabase : ServerlessDatabase​
assignPublicIps : bool​
locationId : string​
labels : string​
backupConfig : BackupConfig​
monitoringConfig : MonitoringConfig​
deletionProtection : bool​

StorageConfig​

storageOptions : StorageOption​
storageSizeLimit : int64​

output only field: storage size limit of dedicated database.

ScalePolicy​

FixedScale​
size : int64​

One of scaleType​

  • fixedScale : FixedScale​

ZonalDatabase​

zoneId : string​

RegionalDatabase​

regionId : string​

DedicatedDatabase​

resourcePresetId : string​
storageConfig : StorageConfig​
scalePolicy : ScalePolicy​
networkId : string​
subnetIds : string​
assignPublicIps : bool​

ServerlessDatabase​

throttlingRcuLimit : int64​

Let's define 1 RU - 1 request unit Let's define 1 RCU - 1 request capacity unit, which is 1 RU per second. If enable_throttling_rcu_limit flag is true, the database will be throttled using throttling_rcu_limit value. Otherwise, the database is throttled using the cloud quotas. If zero, all requests will be blocked until non zero value is set.

storageSizeLimit : int64​

Specify serverless database storage size limit. If zero, default value is applied.

enableThrottlingRcuLimit : bool​

If false, the database is throttled by cloud value.

provisionedRcuLimit : int64​

Specify the number of provisioned RCUs to pay less if the database has predictable load. You will be charged for the provisioned capacity regularly even if this capacity is not fully consumed. You will be charged for the on-demand consumption only if provisioned capacity is consumed.

topicWriteQuota : int64​

write quota for topic service, defined in bytes per second.

BackupConfig​

backupSettings : BackupSettings​

MonitoringConfig​

alerts : Alert​

StorageOption​

storageTypeId : string​
groupCount : int64​

FixedScale​

size : int64​

BackupSettings​

Type​
  • TYPE_UNSPECIFIED

  • SYSTEM

  • USER

StorageClass​
  • STORAGE_CLASS_UNSPECIFIED

  • STANDARD

  • REDUCED_REDUNDANCY

  • STANDARD_IA

  • ONEZONE_IA

  • INTELLIGENT_TIERING

  • GLACIER

  • DEEP_ARCHIVE

  • OUTPOSTS

name : string​

name of backup settings

description : string​

human readable description.

backupSchedule : BackupSchedule​

provide schedule. if empty, backup will be disabled.

backupTimeToLive : google.protobuf.Duration​

provide time to live of backup.

sourcePaths : string​

provide a list of source paths. Each path can be directory, table or even database itself. Each directory (or database) will be traversed recursively and all childs of directory will be included to backup. By default, backup will be created for full database.

sourcePathsToExclude : string​

provide a list of paths to exclude from backup. Each path is a directory, table, or database. Each directory (or database) will be traversed recursively and all childs of directory will be excluded.

type : Type​
storageClass : StorageClass​

Alert​

alertId : string​

output only field.

alertTemplateId : string​

template of the alert.

name : string​

name of the alert.

description : string​

human readable description of the alert.

notificationChannels : NotificationChannel​

the notification channels of the alert.

alertParameters : AlertParameter​

alert parameters to override.

alertThresholds : AlertParameter​

alert paratemers to override.

BackupSchedule​

One of policy​

  • dailyBackupSchedule : DailyBackupSchedule​
  • weeklyBackupSchedule : WeeklyBackupSchedule​
  • recurringBackupSchedule : RecurringBackupSchedule​
nextExecuteTime : google.protobuf.Timestamp​

output only field: when next backup will be executed using provided schedule.

NotificationChannel​

notificationChannelId : string​
notifyAboutStatuses : AlertEvaluationStatus​
repeateNotifyDelayMs : int64​

AlertParameter​

DoubleParameterValue​
name : string​

Required. Parameter name

value : double​

Required. Parameter value

IntegerParameterValue​
name : string​

Required. Parameter name

value : int64​

Required. Parameter value

TextParameterValue​
name : string​

Required. Parameter name

value : string​

Required. Parameter value

TextListParameterValue​
name : string​

Required. Parameter name

values : string​

Required. Parameter value

LabelListParameterValue​
name : string​

Required. Parameter name

values : string​

Required. Parameter value

One of parameter​

  • doubleParameterValue : DoubleParameterValue​
  • integerParameterValue : IntegerParameterValue​
  • textParameterValue : TextParameterValue​
  • textListParameterValue : TextListParameterValue​
  • labelListParameterValue : LabelListParameterValue​

DailyBackupSchedule​

executeTime : google.type.TimeOfDay​

WeeklyBackupSchedule​

daysOfWeek : DaysOfWeekBackupSchedule​

RecurringBackupSchedule​

startTime : google.protobuf.Timestamp​

Timestamp of the first recurrence.

recurrence : string​

An RRULE (https://tools.ietf.org/html/rfc5545#section-3.8.5.3) for how this backup reccurs. The FREQ values of MINUTELY, and SECONDLY are not supported.

DoubleParameterValue​

name : string​

Required. Parameter name

value : double​

Required. Parameter value

IntegerParameterValue​

name : string​

Required. Parameter name

value : int64​

Required. Parameter value

TextParameterValue​

name : string​

Required. Parameter name

value : string​

Required. Parameter value

TextListParameterValue​

name : string​

Required. Parameter name

values : string​

Required. Parameter value

LabelListParameterValue​

name : string​

Required. Parameter name

values : string​

Required. Parameter value

DaysOfWeekBackupSchedule​

days : google.type.DayOfWeek​
executeTime : google.type.TimeOfDay​

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.