Skip to main content
Module

x/windmill/windmill-api/apis/AdminApi.ts

Windmill deno client (separated from the main repo because most of the code is auto-generated from the openapi and not worth committing)
Go to Latest
File
// TODO: better import syntax?import {BaseAPIRequestFactory, RequiredError} from './baseapi.ts';import {Configuration} from '../configuration.ts';import {RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http.ts';import {ObjectSerializer} from '../models/ObjectSerializer.ts';import {ApiException} from './exception.ts';import {canConsumeForm, isCodeInRange} from '../util.ts';import {SecurityAuthentication} from '../auth/auth.ts';

import { EditWorkspaceUser } from '../models/EditWorkspaceUser.ts';import { NewUser } from '../models/NewUser.ts';
/** * no description */export class AdminApiRequestFactory extends BaseAPIRequestFactory {
/** * create user (require admin privilege) * @param workspace * @param newUser new user */ public async createUser(workspace: string, newUser: NewUser, _options?: Configuration): Promise<RequestContext> { let _config = _options || this.configuration;
// verify required parameter 'workspace' is not null or undefined if (workspace === null || workspace === undefined) { throw new RequiredError("AdminApi", "createUser", "workspace"); }

// verify required parameter 'newUser' is not null or undefined if (newUser === null || newUser === undefined) { throw new RequiredError("AdminApi", "createUser", "newUser"); }

// Path Params const localVarPath = '/w/{workspace}/users/add' .replace('{' + 'workspace' + '}', encodeURIComponent(String(workspace)));
// Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")

// Body Params const contentType = ObjectSerializer.getPreferredMediaType([ "application/json" ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( ObjectSerializer.serialize(newUser, "NewUser", ""), contentType ); requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined; // Apply auth methods authMethod = _config.authMethods["bearerAuth"] if (authMethod?.applySecurityAuthentication) { await authMethod?.applySecurityAuthentication(requestContext); } // Apply auth methods authMethod = _config.authMethods["cookieAuth"] if (authMethod?.applySecurityAuthentication) { await authMethod?.applySecurityAuthentication(requestContext); } const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default if (defaultAuth?.applySecurityAuthentication) { await defaultAuth?.applySecurityAuthentication(requestContext); }
return requestContext; }
/** * delete user (require admin privilege) * @param workspace * @param username */ public async deleteUser(workspace: string, username: string, _options?: Configuration): Promise<RequestContext> { let _config = _options || this.configuration;
// verify required parameter 'workspace' is not null or undefined if (workspace === null || workspace === undefined) { throw new RequiredError("AdminApi", "deleteUser", "workspace"); }

// verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new RequiredError("AdminApi", "deleteUser", "username"); }

// Path Params const localVarPath = '/w/{workspace}/users/delete/{username}' .replace('{' + 'workspace' + '}', encodeURIComponent(String(workspace))) .replace('{' + 'username' + '}', encodeURIComponent(String(username)));
// Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")

let authMethod: SecurityAuthentication | undefined; // Apply auth methods authMethod = _config.authMethods["bearerAuth"] if (authMethod?.applySecurityAuthentication) { await authMethod?.applySecurityAuthentication(requestContext); } // Apply auth methods authMethod = _config.authMethods["cookieAuth"] if (authMethod?.applySecurityAuthentication) { await authMethod?.applySecurityAuthentication(requestContext); } const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default if (defaultAuth?.applySecurityAuthentication) { await defaultAuth?.applySecurityAuthentication(requestContext); }
return requestContext; }
/** * update user (require admin privilege) * @param workspace * @param username * @param editWorkspaceUser new user */ public async updateUser(workspace: string, username: string, editWorkspaceUser: EditWorkspaceUser, _options?: Configuration): Promise<RequestContext> { let _config = _options || this.configuration;
// verify required parameter 'workspace' is not null or undefined if (workspace === null || workspace === undefined) { throw new RequiredError("AdminApi", "updateUser", "workspace"); }

// verify required parameter 'username' is not null or undefined if (username === null || username === undefined) { throw new RequiredError("AdminApi", "updateUser", "username"); }

// verify required parameter 'editWorkspaceUser' is not null or undefined if (editWorkspaceUser === null || editWorkspaceUser === undefined) { throw new RequiredError("AdminApi", "updateUser", "editWorkspaceUser"); }

// Path Params const localVarPath = '/w/{workspace}/users/update/{username}' .replace('{' + 'workspace' + '}', encodeURIComponent(String(workspace))) .replace('{' + 'username' + '}', encodeURIComponent(String(username)));
// Make Request Context const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")

// Body Params const contentType = ObjectSerializer.getPreferredMediaType([ "application/json" ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer.stringify( ObjectSerializer.serialize(editWorkspaceUser, "EditWorkspaceUser", ""), contentType ); requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined; // Apply auth methods authMethod = _config.authMethods["bearerAuth"] if (authMethod?.applySecurityAuthentication) { await authMethod?.applySecurityAuthentication(requestContext); } // Apply auth methods authMethod = _config.authMethods["cookieAuth"] if (authMethod?.applySecurityAuthentication) { await authMethod?.applySecurityAuthentication(requestContext); } const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default if (defaultAuth?.applySecurityAuthentication) { await defaultAuth?.applySecurityAuthentication(requestContext); }
return requestContext; }
}
export class AdminApiResponseProcessor {
/** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects * * @params response Response returned by the server for a request to createUser * @throws ApiException if the response code was not in [200, 299] */ public async createUser(response: ResponseContext): Promise<string > { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("201", response.httpStatusCode)) { const body: string = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "string", "" ) as string; return body; }
// Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body: string = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "string", "" ) as string; return body; }
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); }
/** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects * * @params response Response returned by the server for a request to deleteUser * @throws ApiException if the response code was not in [200, 299] */ public async deleteUser(response: ResponseContext): Promise<string > { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { const body: string = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "string", "" ) as string; return body; }
// Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body: string = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "string", "" ) as string; return body; }
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); }
/** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects * * @params response Response returned by the server for a request to updateUser * @throws ApiException if the response code was not in [200, 299] */ public async updateUser(response: ResponseContext): Promise<string > { const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (isCodeInRange("200", response.httpStatusCode)) { const body: string = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "string", "" ) as string; return body; }
// Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body: string = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), "string", "" ) as string; return body; }
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); }
}