( projectId: string, instanceName: string, location: DatabaseLocation, databaseType: DatabaseInstanceType, )
| 105 | * @param databaseType type of the database being created. |
| 106 | */ |
| 107 | export async function createInstance( |
| 108 | projectId: string, |
| 109 | instanceName: string, |
| 110 | location: DatabaseLocation, |
| 111 | databaseType: DatabaseInstanceType, |
| 112 | ): Promise<DatabaseInstance> { |
| 113 | try { |
| 114 | const response = await apiClient.request({ |
| 115 | method: "POST", |
| 116 | path: `/projects/${projectId}/locations/${location}/instances`, |
| 117 | queryParams: { databaseId: instanceName }, |
| 118 | body: { type: databaseType }, |
| 119 | timeout: TIMEOUT_MILLIS, |
| 120 | }); |
| 121 | |
| 122 | return convertDatabaseInstance(response.body); |
| 123 | } catch (err: any) { |
| 124 | logger.debug(err.message); |
| 125 | return utils.reject( |
| 126 | `Failed to create instance: ${instanceName}. See firebase-debug.log for more details.`, |
| 127 | { |
| 128 | code: 2, |
| 129 | original: err, |
| 130 | }, |
| 131 | ); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Checks if an instance with the specified name can be created. |
no test coverage detected
searching dependent graphs…