/* 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, DeploymentConfigV2, DeploymentV2, } from '../models'; import { ApiErrorFromJSON, ApiErrorToJSON, DeploymentConfigV2FromJSON, DeploymentConfigV2ToJSON, DeploymentV2FromJSON, DeploymentV2ToJSON, } from '../models'; export interface CreateDeploymentRequest { appId: string; buildId: number; deploymentConfigV2: DeploymentConfigV2; } export interface GetDeploymentInfoRequest { appId: string; deploymentId: number; } export interface GetDeploymentsRequest { appId: string; } export interface GetLatestDeploymentRequest { appId: string; } /** * DeploymentV2Api - interface * * @export * @interface DeploymentV2ApiInterface */ export interface DeploymentV2ApiInterface { /** * Create a new [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment). Creating a new deployment means all new rooms created will use the latest deployment configuration, but existing games in progress will not be affected. * @param {string} appId * @param {number} buildId * @param {DeploymentConfigV2} deploymentConfigV2 * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof DeploymentV2ApiInterface */ createDeploymentRaw(requestParameters: CreateDeploymentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Create a new [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment). Creating a new deployment means all new rooms created will use the latest deployment configuration, but existing games in progress will not be affected. */ createDeployment(appId: string, buildId: number, deploymentConfigV2: DeploymentConfigV2, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * Get details for a [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment). * @param {string} appId * @param {number} deploymentId * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof DeploymentV2ApiInterface */ getDeploymentInfoRaw(requestParameters: GetDeploymentInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Get details for a [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment). */ getDeploymentInfo(appId: string, deploymentId: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** * Returns an array of [deployments](https://hathora.dev/docs/concepts/hathora-entities#deployment) for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). * @param {string} appId * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof DeploymentV2ApiInterface */ getDeploymentsRaw(requestParameters: GetDeploymentsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>>; /** * Returns an array of [deployments](https://hathora.dev/docs/concepts/hathora-entities#deployment) for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). */ getDeployments(appId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Get the latest [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment) for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). * @param {string} appId * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof DeploymentV2ApiInterface */ getLatestDeploymentRaw(requestParameters: GetLatestDeploymentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** * Get the latest [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment) for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). */ getLatestDeployment(appId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; } /** * */ export class DeploymentV2Api extends runtime.BaseAPI implements DeploymentV2ApiInterface { /** * Create a new [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment). Creating a new deployment means all new rooms created will use the latest deployment configuration, but existing games in progress will not be affected. */ async createDeploymentRaw(requestParameters: CreateDeploymentRequest, 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 createDeployment.'); } if (requestParameters.buildId === null || requestParameters.buildId === undefined) { throw new runtime.RequiredError('buildId','Required parameter requestParameters.buildId was null or undefined when calling createDeployment.'); } if (requestParameters.deploymentConfigV2 === null || requestParameters.deploymentConfigV2 === undefined) { throw new runtime.RequiredError('deploymentConfigV2','Required parameter requestParameters.deploymentConfigV2 was null or undefined when calling createDeployment.'); } 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: `/deployments/v2/{appId}/create/{buildId}`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))).replace(`{${"buildId"}}`, encodeURIComponent(String(requestParameters.buildId))), method: 'POST', headers: headerParameters, query: queryParameters, body: DeploymentConfigV2ToJSON(requestParameters.deploymentConfigV2), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => DeploymentV2FromJSON(jsonValue)); } /** * Create a new [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment). Creating a new deployment means all new rooms created will use the latest deployment configuration, but existing games in progress will not be affected. */ async createDeployment(appId: string, buildId: number, deploymentConfigV2: DeploymentConfigV2, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createDeploymentRaw({ appId: appId, buildId: buildId, deploymentConfigV2: deploymentConfigV2 }, initOverrides); return await response.value(); } /** * Get details for a [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment). */ async getDeploymentInfoRaw(requestParameters: GetDeploymentInfoRequest, 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 getDeploymentInfo.'); } if (requestParameters.deploymentId === null || requestParameters.deploymentId === undefined) { throw new runtime.RequiredError('deploymentId','Required parameter requestParameters.deploymentId was null or undefined when calling getDeploymentInfo.'); } 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: `/deployments/v2/{appId}/info/{deploymentId}`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))).replace(`{${"deploymentId"}}`, encodeURIComponent(String(requestParameters.deploymentId))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => DeploymentV2FromJSON(jsonValue)); } /** * Get details for a [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment). */ async getDeploymentInfo(appId: string, deploymentId: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getDeploymentInfoRaw({ appId: appId, deploymentId: deploymentId }, initOverrides); return await response.value(); } /** * Returns an array of [deployments](https://hathora.dev/docs/concepts/hathora-entities#deployment) for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). */ async getDeploymentsRaw(requestParameters: GetDeploymentsRequest, 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 getDeployments.'); } 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: `/deployments/v2/{appId}/list`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(DeploymentV2FromJSON)); } /** * Returns an array of [deployments](https://hathora.dev/docs/concepts/hathora-entities#deployment) for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). */ async getDeployments(appId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const response = await this.getDeploymentsRaw({ appId: appId }, initOverrides); return await response.value(); } /** * Get the latest [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment) for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). */ async getLatestDeploymentRaw(requestParameters: GetLatestDeploymentRequest, 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 getLatestDeployment.'); } 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: `/deployments/v2/{appId}/latest`.replace(`{${"appId"}}`, encodeURIComponent(String(requestParameters.appId))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => DeploymentV2FromJSON(jsonValue)); } /** * Get the latest [deployment](https://hathora.dev/docs/concepts/hathora-entities#deployment) for an [application](https://hathora.dev/docs/concepts/hathora-entities#application). */ async getLatestDeployment(appId: string, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getLatestDeploymentRaw({ appId: appId }, initOverrides); return await response.value(); } }