AuthenticationServiceApi.ts•15.1 kB
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi';
import {Configuration} from '../configuration';
import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http';
import {ObjectSerializer} from '../models/ObjectSerializer';
import {ApiException} from './exception';
import {canConsumeForm, isCodeInRange} from '../util';
import {SecurityAuthentication} from '../auth/auth';
import { Authentication } from '../models/Authentication';
import { ListAuthenticationsResponse } from '../models/ListAuthenticationsResponse';
/**
* no description
*/
export class AuthenticationServiceApiRequestFactory extends BaseAPIRequestFactory {
/**
* @param id
*/
public async deleteAuthToken(id: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new RequiredError("AuthenticationServiceApi", "deleteAuthToken", "id");
}
// Path Params
const localVarPath = '/auth/v1/tokens/{id}'
.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
// 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);
}
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* @param expiresAt
*/
public async expireAuthSelf(expiresAt?: Date, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// Path Params
const localVarPath = '/auth/v1/self/expire';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
if (expiresAt !== undefined) {
requestContext.setQueryParam("expiresAt", ObjectSerializer.serialize(expiresAt, "Date", "date-time"));
}
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["bearerAuth"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
*/
public async getAuthSelf(_options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// Path Params
const localVarPath = '/auth/v1/self';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
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);
}
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* @param id
*/
public async getAuthToken(id: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new RequiredError("AuthenticationServiceApi", "getAuthToken", "id");
}
// Path Params
const localVarPath = '/auth/v1/tokens/{id}'
.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
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);
}
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* @param method
* @param limit
* @param pageToken
*/
public async listAuthTokens(method?: 'METHOD_NONE' | 'METHOD_TOKEN' | 'METHOD_OIDC' | 'METHOD_KUBERNETES' | 'METHOD_GITHUB' | 'METHOD_JWT' | 'METHOD_CLOUD', limit?: number, pageToken?: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// Path Params
const localVarPath = '/auth/v1/tokens';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
if (method !== undefined) {
requestContext.setQueryParam("method", ObjectSerializer.serialize(method, "'METHOD_NONE' | 'METHOD_TOKEN' | 'METHOD_OIDC' | 'METHOD_KUBERNETES' | 'METHOD_GITHUB' | 'METHOD_JWT' | 'METHOD_CLOUD'", "enum"));
}
// Query Params
if (limit !== undefined) {
requestContext.setQueryParam("limit", ObjectSerializer.serialize(limit, "number", "int32"));
}
// Query Params
if (pageToken !== undefined) {
requestContext.setQueryParam("pageToken", ObjectSerializer.serialize(pageToken, "string", ""));
}
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["bearerAuth"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
}
export class AuthenticationServiceApiResponseProcessor {
/**
* 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 deleteAuthToken
* @throws ApiException if the response code was not in [200, 299]
*/
public async deleteAuthTokenWithHttpInfo(response: ResponseContext): Promise<HttpInfo<void >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: void = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"void", ""
) as void;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 expireAuthSelf
* @throws ApiException if the response code was not in [200, 299]
*/
public async expireAuthSelfWithHttpInfo(response: ResponseContext): Promise<HttpInfo<void >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: void = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"void", ""
) as void;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 getAuthSelf
* @throws ApiException if the response code was not in [200, 299]
*/
public async getAuthSelfWithHttpInfo(response: ResponseContext): Promise<HttpInfo<Authentication >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: Authentication = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Authentication", ""
) as Authentication;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: Authentication = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Authentication", ""
) as Authentication;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 getAuthToken
* @throws ApiException if the response code was not in [200, 299]
*/
public async getAuthTokenWithHttpInfo(response: ResponseContext): Promise<HttpInfo<Authentication >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: Authentication = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Authentication", ""
) as Authentication;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: Authentication = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Authentication", ""
) as Authentication;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 listAuthTokens
* @throws ApiException if the response code was not in [200, 299]
*/
public async listAuthTokensWithHttpInfo(response: ResponseContext): Promise<HttpInfo<ListAuthenticationsResponse >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: ListAuthenticationsResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ListAuthenticationsResponse", ""
) as ListAuthenticationsResponse;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: ListAuthenticationsResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ListAuthenticationsResponse", ""
) as ListAuthenticationsResponse;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}