/* tslint:disable */ /* eslint-disable */ /** * Hathora Cloud API * Welcome to the Hathora Cloud API documentation! Learn how to use the Hathora Cloud APIs to build and scale your game servers globally. * * The version of the OpenAPI document: 0.0.1 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import type { ApiError, ConnectionInfoV2, CreateRoomParams, PickRoomExcludeKeyofRoomAllocations, Room, RoomConnectionData, UpdateRoomConfigParams, } from '../models'; import { ApiErrorFromJSON, ApiErrorToJSON, ConnectionInfoV2FromJSON, ConnectionInfoV2ToJSON, CreateRoomParamsFromJSON, CreateRoomParamsToJSON, PickRoomExcludeKeyofRoomAllocationsFromJSON, PickRoomExcludeKeyofRoomAllocationsToJSON, RoomFromJSON, RoomToJSON, RoomConnectionDataFromJSON, RoomConnectionDataToJSON, UpdateRoomConfigParamsFromJSON, UpdateRoomConfigParamsToJSON, } from '../models'; export interface CreateRoomRequest { appId: string; createRoomParams: CreateRoomParams; roomId?: string; } export interface DestroyRoomRequest { appId: string; roomId: string; } export interface GetActiveRoomsForProcessRequest { appId: string; processId: string; } export interface GetConnectionInfoRequest { appId: string; roomId: string; } export interface GetInactiveRoomsForProcessRequest { appId: string; processId: string; } export interface GetRoomInfoRequest { appId: string; roomId: string; } export interface SuspendRoomV2DeprecatedRequest { appId: string; roomId: string; } export interface UpdateRoomConfigRequest { appId: string; roomId: string; updateRoomConfigParams: UpdateRoomConfigParams; } /** * RoomV2Api - interface * * @export * @interface RoomV2ApiInterface */ export interface RoomV2ApiInterface { /** * Create a new [room](https://hathora.dev/docs/concepts/hathora-entities#room) for an existing [application](https://hathora.dev/docs/concepts/hathora-entities#application). Poll the [`GetConnectionInfo()`](https://hathora.dev/api#tag/RoomV2/operation/GetConnectionInfo) endpoint to get connection details for an active room. * @param {string} appId * @param {CreateRoomParams} createRoomParams * @param {string} [roomId] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof RoomV2ApiInterface */ createRoomRaw(requestParameters: CreateRoomRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Create a new [room](https://hathora.dev/docs/concepts/hathora-entities#room) for an existing [application](https://hathora.dev/docs/concepts/hathora-entities#application). Poll the [`GetConnectionInfo()`](https://hathora.dev/api#tag/RoomV2/operation/GetConnectionInfo) endpoint to get connection details for an active room. */ createRoom(appId: string, createRoomParams: CreateRoomParams, roomId?: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * Destroy a [room](https://hathora.dev/docs/concepts/hathora-entities#room). All associated metadata is deleted. * @param {string} appId * @param {string} roomId * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof RoomV2ApiInterface */ destroyRoomRaw(requestParameters: DestroyRoomRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Destroy a [room](https://hathora.dev/docs/concepts/hathora-entities#room). All associated metadata is deleted. */ destroyRoom(appId: string, roomId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * Get all active [rooms](https://hathora.dev/docs/concepts/hathora-entities#room) for a given [process](https://hathora.dev/docs/concepts/hathora-entities#process). * @param {string} appId * @param {string} processId * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof RoomV2ApiInterface */ getActiveRoomsForProcessRaw(requestParameters: GetActiveRoomsForProcessRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>>; /** * Get all active [rooms](https://hathora.dev/docs/concepts/hathora-entities#room) for a given [process](https://hathora.dev/docs/concepts/hathora-entities#process). */ getActiveRoomsForProcess(appId: string, processId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Poll this endpoint to get connection details to a [room](https://hathora.dev/docs/concepts/hathora-entities#room). Clients can call this endpoint without authentication. * @param {string} appId * @param {string} roomId * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof RoomV2ApiInterface */ getConnectionInfoRaw(requestParameters: GetConnectionInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Poll this endpoint to get connection details to a [room](https://hathora.dev/docs/concepts/hathora-entities#room). Clients can call this endpoint without authentication. */ getConnectionInfo(appId: string, roomId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * Get all inactive [rooms](https://hathora.dev/docs/concepts/hathora-entities#room) for a given [process](https://hathora.dev/docs/concepts/hathora-entities#process). * @param {string} appId * @param {string} processId * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof RoomV2ApiInterface */ getInactiveRoomsForProcessRaw(requestParameters: GetInactiveRoomsForProcessRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>>; /** * Get all inactive [rooms](https://hathora.dev/docs/concepts/hathora-entities#room) for a given [process](https://hathora.dev/docs/concepts/hathora-entities#process). */ getInactiveRoomsForProcess(appId: string, processId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Retreive current and historical allocation data for a [room](https://hathora.dev/docs/concepts/hathora-entities#room). * @param {string} appId * @param {string} roomId * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof RoomV2ApiInterface */ getRoomInfoRaw(requestParameters: GetRoomInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Retreive current and historical allocation data for a [room](https://hathora.dev/docs/concepts/hathora-entities#room). */ getRoomInfo(appId: string, roomId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * Suspend a [room](https://hathora.dev/docs/concepts/hathora-entities#room). The room is unallocated from the process but can be rescheduled later using the same `roomId`. * @param {string} appId * @param {string} roomId * @param {*} [options] Override http request option. * @deprecated * @throws {RequiredError} * @memberof RoomV2ApiInterface */ suspendRoomV2DeprecatedRaw(requestParameters: SuspendRoomV2DeprecatedRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Suspend a [room](https://hathora.dev/docs/concepts/hathora-entities#room). The room is unallocated from the process but can be rescheduled later using the same `roomId`. */ suspendRoomV2Deprecated(appId: string, roomId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * * @param {string} appId * @param {string} roomId * @param {UpdateRoomConfigParams} updateRoomConfigParams * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof RoomV2ApiInterface */ updateRoomConfigRaw(requestParameters: UpdateRoomConfigRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** */ updateRoomConfig(appId: string, roomId: string, updateRoomConfigParams: UpdateRoomConfigParams, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; } /** * */ export class RoomV2Api extends runtime.BaseAPI implements RoomV2ApiInterface { /** * Create a new [room](https://hathora.dev/docs/concepts/hathora-entities#room) for an existing [application](https://hathora.dev/docs/concepts/hathora-entities#application). Poll the [`GetConnectionInfo()`](https://hathora.dev/api#tag/RoomV2/operation/GetConnectionInfo) endpoint to get connection details for an active room. */ async createRoomRaw(requestParameters: CreateRoomRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.appId === null || requestParameters.appId === undefined) { throw new runtime.RequiredError('appId','Required parameter requestParameters.appId was null or undefined when calling createRoom.'); } if (requestParameters.createRoomParams === null || requestParameters.createRoomParams === undefined) { throw new runtime.RequiredError('createRoomParams','Required parameter requestParameters.createRoomParams was null or undefined when calling createRoom.'); } const queryParameters: any = {}; if (requestParameters.roomId !== undefined) { queryParameters['roomId'] = requestParameters.roomId; } const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("hathoraDevToken", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/rooms/v2/{appId}/create`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))), method: 'POST', headers: headerParameters, query: queryParameters, body: CreateRoomParamsToJSON(requestParameters.createRoomParams), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => RoomConnectionDataFromJSON(jsonValue)); } /** * Create a new [room](https://hathora.dev/docs/concepts/hathora-entities#room) for an existing [application](https://hathora.dev/docs/concepts/hathora-entities#application). Poll the [`GetConnectionInfo()`](https://hathora.dev/api#tag/RoomV2/operation/GetConnectionInfo) endpoint to get connection details for an active room. */ async createRoom(appId: string, createRoomParams: CreateRoomParams, roomId?: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createRoomRaw({ appId: appId, createRoomParams: createRoomParams, roomId: roomId }, initOverrides); return await response.value(); } /** * Destroy a [room](https://hathora.dev/docs/concepts/hathora-entities#room). All associated metadata is deleted. */ async destroyRoomRaw(requestParameters: DestroyRoomRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.appId === null || requestParameters.appId === undefined) { throw new runtime.RequiredError('appId','Required parameter requestParameters.appId was null or undefined when calling destroyRoom.'); } if (requestParameters.roomId === null || requestParameters.roomId === undefined) { throw new runtime.RequiredError('roomId','Required parameter requestParameters.roomId was null or undefined when calling destroyRoom.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("hathoraDevToken", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/rooms/v2/{appId}/destroy/{roomId}`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))).replace(`{${"roomId"}}`, encodeURIComponent(String(requestParameters.roomId))), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Destroy a [room](https://hathora.dev/docs/concepts/hathora-entities#room). All associated metadata is deleted. */ async destroyRoom(appId: string, roomId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.destroyRoomRaw({ appId: appId, roomId: roomId }, initOverrides); } /** * Get all active [rooms](https://hathora.dev/docs/concepts/hathora-entities#room) for a given [process](https://hathora.dev/docs/concepts/hathora-entities#process). */ async getActiveRoomsForProcessRaw(requestParameters: GetActiveRoomsForProcessRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { if (requestParameters.appId === null || requestParameters.appId === undefined) { throw new runtime.RequiredError('appId','Required parameter requestParameters.appId was null or undefined when calling getActiveRoomsForProcess.'); } if (requestParameters.processId === null || requestParameters.processId === undefined) { throw new runtime.RequiredError('processId','Required parameter requestParameters.processId was null or undefined when calling getActiveRoomsForProcess.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("hathoraDevToken", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/rooms/v2/{appId}/list/{processId}/active`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))).replace(`{${"processId"}}`, encodeURIComponent(String(requestParameters.processId))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PickRoomExcludeKeyofRoomAllocationsFromJSON)); } /** * Get all active [rooms](https://hathora.dev/docs/concepts/hathora-entities#room) for a given [process](https://hathora.dev/docs/concepts/hathora-entities#process). */ async getActiveRoomsForProcess(appId: string, processId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const response = await this.getActiveRoomsForProcessRaw({ appId: appId, processId: processId }, initOverrides); return await response.value(); } /** * Poll this endpoint to get connection details to a [room](https://hathora.dev/docs/concepts/hathora-entities#room). Clients can call this endpoint without authentication. */ async getConnectionInfoRaw(requestParameters: GetConnectionInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.appId === null || requestParameters.appId === undefined) { throw new runtime.RequiredError('appId','Required parameter requestParameters.appId was null or undefined when calling getConnectionInfo.'); } if (requestParameters.roomId === null || requestParameters.roomId === undefined) { throw new runtime.RequiredError('roomId','Required parameter requestParameters.roomId was null or undefined when calling getConnectionInfo.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ path: `/rooms/v2/{appId}/connectioninfo/{roomId}`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))).replace(`{${"roomId"}}`, encodeURIComponent(String(requestParameters.roomId))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ConnectionInfoV2FromJSON(jsonValue)); } /** * Poll this endpoint to get connection details to a [room](https://hathora.dev/docs/concepts/hathora-entities#room). Clients can call this endpoint without authentication. */ async getConnectionInfo(appId: string, roomId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getConnectionInfoRaw({ appId: appId, roomId: roomId }, initOverrides); return await response.value(); } /** * Get all inactive [rooms](https://hathora.dev/docs/concepts/hathora-entities#room) for a given [process](https://hathora.dev/docs/concepts/hathora-entities#process). */ async getInactiveRoomsForProcessRaw(requestParameters: GetInactiveRoomsForProcessRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { if (requestParameters.appId === null || requestParameters.appId === undefined) { throw new runtime.RequiredError('appId','Required parameter requestParameters.appId was null or undefined when calling getInactiveRoomsForProcess.'); } if (requestParameters.processId === null || requestParameters.processId === undefined) { throw new runtime.RequiredError('processId','Required parameter requestParameters.processId was null or undefined when calling getInactiveRoomsForProcess.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("hathoraDevToken", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/rooms/v2/{appId}/list/{processId}/inactive`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))).replace(`{${"processId"}}`, encodeURIComponent(String(requestParameters.processId))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PickRoomExcludeKeyofRoomAllocationsFromJSON)); } /** * Get all inactive [rooms](https://hathora.dev/docs/concepts/hathora-entities#room) for a given [process](https://hathora.dev/docs/concepts/hathora-entities#process). */ async getInactiveRoomsForProcess(appId: string, processId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const response = await this.getInactiveRoomsForProcessRaw({ appId: appId, processId: processId }, initOverrides); return await response.value(); } /** * Retreive current and historical allocation data for a [room](https://hathora.dev/docs/concepts/hathora-entities#room). */ async getRoomInfoRaw(requestParameters: GetRoomInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.appId === null || requestParameters.appId === undefined) { throw new runtime.RequiredError('appId','Required parameter requestParameters.appId was null or undefined when calling getRoomInfo.'); } if (requestParameters.roomId === null || requestParameters.roomId === undefined) { throw new runtime.RequiredError('roomId','Required parameter requestParameters.roomId was null or undefined when calling getRoomInfo.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("hathoraDevToken", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/rooms/v2/{appId}/info/{roomId}`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))).replace(`{${"roomId"}}`, encodeURIComponent(String(requestParameters.roomId))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => RoomFromJSON(jsonValue)); } /** * Retreive current and historical allocation data for a [room](https://hathora.dev/docs/concepts/hathora-entities#room). */ async getRoomInfo(appId: string, roomId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getRoomInfoRaw({ appId: appId, roomId: roomId }, initOverrides); return await response.value(); } /** * Suspend a [room](https://hathora.dev/docs/concepts/hathora-entities#room). The room is unallocated from the process but can be rescheduled later using the same `roomId`. */ async suspendRoomV2DeprecatedRaw(requestParameters: SuspendRoomV2DeprecatedRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.appId === null || requestParameters.appId === undefined) { throw new runtime.RequiredError('appId','Required parameter requestParameters.appId was null or undefined when calling suspendRoomV2Deprecated.'); } if (requestParameters.roomId === null || requestParameters.roomId === undefined) { throw new runtime.RequiredError('roomId','Required parameter requestParameters.roomId was null or undefined when calling suspendRoomV2Deprecated.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("hathoraDevToken", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/rooms/v2/{appId}/suspend/{roomId}`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))).replace(`{${"roomId"}}`, encodeURIComponent(String(requestParameters.roomId))), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Suspend a [room](https://hathora.dev/docs/concepts/hathora-entities#room). The room is unallocated from the process but can be rescheduled later using the same `roomId`. */ async suspendRoomV2Deprecated(appId: string, roomId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.suspendRoomV2DeprecatedRaw({ appId: appId, roomId: roomId }, initOverrides); } /** */ async updateRoomConfigRaw(requestParameters: UpdateRoomConfigRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.appId === null || requestParameters.appId === undefined) { throw new runtime.RequiredError('appId','Required parameter requestParameters.appId was null or undefined when calling updateRoomConfig.'); } if (requestParameters.roomId === null || requestParameters.roomId === undefined) { throw new runtime.RequiredError('roomId','Required parameter requestParameters.roomId was null or undefined when calling updateRoomConfig.'); } if (requestParameters.updateRoomConfigParams === null || requestParameters.updateRoomConfigParams === undefined) { throw new runtime.RequiredError('updateRoomConfigParams','Required parameter requestParameters.updateRoomConfigParams was null or undefined when calling updateRoomConfig.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("hathoraDevToken", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/rooms/v2/{appId}/update/{roomId}`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))).replace(`{${"roomId"}}`, encodeURIComponent(String(requestParameters.roomId))), method: 'POST', headers: headerParameters, query: queryParameters, body: UpdateRoomConfigParamsToJSON(requestParameters.updateRoomConfigParams), }, initOverrides); return new runtime.VoidApiResponse(response); } /** */ async updateRoomConfig(appId: string, roomId: string, updateRoomConfigParams: UpdateRoomConfigParams, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.updateRoomConfigRaw({ appId: appId, roomId: roomId, updateRoomConfigParams: updateRoomConfigParams }, initOverrides); } }