/* 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, ProcessStatus, ProcessV2, Region, } from '../models'; import { ApiErrorFromJSON, ApiErrorToJSON, ProcessStatusFromJSON, ProcessStatusToJSON, ProcessV2FromJSON, ProcessV2ToJSON, RegionFromJSON, RegionToJSON, } from '../models'; export interface CreateProcessRequest { appId: string; region: Region; } export interface GetLatestProcessesRequest { appId: string; status?: Array; region?: Array; } export interface GetProcessInfoRequest { appId: string; processId: string; } export interface StopProcessRequest { appId: string; processId: string; } /** * ProcessesV2Api - interface * * @export * @interface ProcessesV2ApiInterface */ export interface ProcessesV2ApiInterface { /** * Creates a [process](https://hathora.dev/docs/concepts/hathora-entities#process) without a room. Use this to pre-allocate processes ahead of time so that subsequent room assignment via [CreateRoom()](https://hathora.dev/api#tag/RoomV2/operation/CreateRoom) can be instant. * @param {string} appId * @param {Region} region * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ProcessesV2ApiInterface */ createProcessRaw(requestParameters: CreateProcessRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Creates a [process](https://hathora.dev/docs/concepts/hathora-entities#process) without a room. Use this to pre-allocate processes ahead of time so that subsequent room assignment via [CreateRoom()](https://hathora.dev/api#tag/RoomV2/operation/CreateRoom) can be instant. */ createProcess(appId: string, region: Region, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * Retrieve the 10 most recent [processes](https://hathora.dev/docs/concepts/hathora-entities#process) objects for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). Filter the array by optionally passing in a `status` or `region`. * @param {string} appId * @param {Array} [status] * @param {Array} [region] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ProcessesV2ApiInterface */ getLatestProcessesRaw(requestParameters: GetLatestProcessesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>>; /** * Retrieve the 10 most recent [processes](https://hathora.dev/docs/concepts/hathora-entities#process) objects for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). Filter the array by optionally passing in a `status` or `region`. */ getLatestProcesses(appId: string, status?: Array, region?: Array, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Get details for a [process](https://hathora.dev/docs/concepts/hathora-entities#process). * @param {string} appId * @param {string} processId * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ProcessesV2ApiInterface */ getProcessInfoRaw(requestParameters: GetProcessInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Get details for a [process](https://hathora.dev/docs/concepts/hathora-entities#process). */ getProcessInfo(appId: string, processId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * Stops a [process](https://hathora.dev/docs/concepts/hathora-entities#process) immediately. * @param {string} appId * @param {string} processId * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ProcessesV2ApiInterface */ stopProcessRaw(requestParameters: StopProcessRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Stops a [process](https://hathora.dev/docs/concepts/hathora-entities#process) immediately. */ stopProcess(appId: string, processId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; } /** * */ export class ProcessesV2Api extends runtime.BaseAPI implements ProcessesV2ApiInterface { /** * Creates a [process](https://hathora.dev/docs/concepts/hathora-entities#process) without a room. Use this to pre-allocate processes ahead of time so that subsequent room assignment via [CreateRoom()](https://hathora.dev/api#tag/RoomV2/operation/CreateRoom) can be instant. */ async createProcessRaw(requestParameters: CreateProcessRequest, 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 createProcess.'); } if (requestParameters.region === null || requestParameters.region === undefined) { throw new runtime.RequiredError('region','Required parameter requestParameters.region was null or undefined when calling createProcess.'); } 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: `/processes/v2/{appId}/create/{region}`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))).replace(`{${"region"}}`, encodeURIComponent(String(requestParameters.region))), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ProcessV2FromJSON(jsonValue)); } /** * Creates a [process](https://hathora.dev/docs/concepts/hathora-entities#process) without a room. Use this to pre-allocate processes ahead of time so that subsequent room assignment via [CreateRoom()](https://hathora.dev/api#tag/RoomV2/operation/CreateRoom) can be instant. */ async createProcess(appId: string, region: Region, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createProcessRaw({ appId: appId, region: region }, initOverrides); return await response.value(); } /** * Retrieve the 10 most recent [processes](https://hathora.dev/docs/concepts/hathora-entities#process) objects for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). Filter the array by optionally passing in a `status` or `region`. */ async getLatestProcessesRaw(requestParameters: GetLatestProcessesRequest, 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 getLatestProcesses.'); } const queryParameters: any = {}; if (requestParameters.status) { queryParameters['status'] = requestParameters.status; } if (requestParameters.region) { queryParameters['region'] = requestParameters.region; } 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: `/processes/v2/{appId}/list/latest`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ProcessV2FromJSON)); } /** * Retrieve the 10 most recent [processes](https://hathora.dev/docs/concepts/hathora-entities#process) objects for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). Filter the array by optionally passing in a `status` or `region`. */ async getLatestProcesses(appId: string, status?: Array, region?: Array, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const response = await this.getLatestProcessesRaw({ appId: appId, status: status, region: region }, initOverrides); return await response.value(); } /** * Get details for a [process](https://hathora.dev/docs/concepts/hathora-entities#process). */ async getProcessInfoRaw(requestParameters: GetProcessInfoRequest, 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 getProcessInfo.'); } if (requestParameters.processId === null || requestParameters.processId === undefined) { throw new runtime.RequiredError('processId','Required parameter requestParameters.processId was null or undefined when calling getProcessInfo.'); } 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: `/processes/v2/{appId}/info/{processId}`.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) => ProcessV2FromJSON(jsonValue)); } /** * Get details for a [process](https://hathora.dev/docs/concepts/hathora-entities#process). */ async getProcessInfo(appId: string, processId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getProcessInfoRaw({ appId: appId, processId: processId }, initOverrides); return await response.value(); } /** * Stops a [process](https://hathora.dev/docs/concepts/hathora-entities#process) immediately. */ async stopProcessRaw(requestParameters: StopProcessRequest, 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 stopProcess.'); } if (requestParameters.processId === null || requestParameters.processId === undefined) { throw new runtime.RequiredError('processId','Required parameter requestParameters.processId was null or undefined when calling stopProcess.'); } 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: `/processes/v2/{appId}/stop/{processId}`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))).replace(`{${"processId"}}`, encodeURIComponent(String(requestParameters.processId))), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Stops a [process](https://hathora.dev/docs/concepts/hathora-entities#process) immediately. */ async stopProcess(appId: string, processId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.stopProcessRaw({ appId: appId, processId: processId }, initOverrides); } }