OFREPServiceApi.ts•11 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 { BulkEvaluationResponse } from '../models/BulkEvaluationResponse';
import { EvaluateBulkRequest } from '../models/EvaluateBulkRequest';
import { EvaluateFlagRequest } from '../models/EvaluateFlagRequest';
import { EvaluatedFlag } from '../models/EvaluatedFlag';
import { GetProviderConfigurationResponse } from '../models/GetProviderConfigurationResponse';
/**
* no description
*/
export class OFREPServiceApiRequestFactory extends BaseAPIRequestFactory {
/**
* OFREP provider configuration
*/
public async ofrepConfiguration(_options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// Path Params
const localVarPath = '/ofrep/v1/configuration';
// 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;
}
/**
* OFREP bulk flag evaluation
* @param evaluateBulkRequest
*/
public async ofrepEvaluateBulk(evaluateBulkRequest: EvaluateBulkRequest, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'evaluateBulkRequest' is not null or undefined
if (evaluateBulkRequest === null || evaluateBulkRequest === undefined) {
throw new RequiredError("OFREPServiceApi", "ofrepEvaluateBulk", "evaluateBulkRequest");
}
// Path Params
const localVarPath = '/ofrep/v1/evaluate/flags';
// 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(evaluateBulkRequest, "EvaluateBulkRequest", ""),
contentType
);
requestContext.setBody(serializedBody);
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;
}
/**
* OFREP single flag evaluation
* @param key
* @param evaluateFlagRequest
*/
public async ofrepEvaluateFlag(key: string, evaluateFlagRequest: EvaluateFlagRequest, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'key' is not null or undefined
if (key === null || key === undefined) {
throw new RequiredError("OFREPServiceApi", "ofrepEvaluateFlag", "key");
}
// verify required parameter 'evaluateFlagRequest' is not null or undefined
if (evaluateFlagRequest === null || evaluateFlagRequest === undefined) {
throw new RequiredError("OFREPServiceApi", "ofrepEvaluateFlag", "evaluateFlagRequest");
}
// Path Params
const localVarPath = '/ofrep/v1/evaluate/flags/{key}'
.replace('{' + 'key' + '}', encodeURIComponent(String(key)));
// 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(evaluateFlagRequest, "EvaluateFlagRequest", ""),
contentType
);
requestContext.setBody(serializedBody);
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 OFREPServiceApiResponseProcessor {
/**
* 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 ofrepConfiguration
* @throws ApiException if the response code was not in [200, 299]
*/
public async ofrepConfigurationWithHttpInfo(response: ResponseContext): Promise<HttpInfo<GetProviderConfigurationResponse >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: GetProviderConfigurationResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"GetProviderConfigurationResponse", ""
) as GetProviderConfigurationResponse;
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: GetProviderConfigurationResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"GetProviderConfigurationResponse", ""
) as GetProviderConfigurationResponse;
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 ofrepEvaluateBulk
* @throws ApiException if the response code was not in [200, 299]
*/
public async ofrepEvaluateBulkWithHttpInfo(response: ResponseContext): Promise<HttpInfo<BulkEvaluationResponse >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: BulkEvaluationResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"BulkEvaluationResponse", ""
) as BulkEvaluationResponse;
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: BulkEvaluationResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"BulkEvaluationResponse", ""
) as BulkEvaluationResponse;
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 ofrepEvaluateFlag
* @throws ApiException if the response code was not in [200, 299]
*/
public async ofrepEvaluateFlagWithHttpInfo(response: ResponseContext): Promise<HttpInfo<EvaluatedFlag >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: EvaluatedFlag = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"EvaluatedFlag", ""
) as EvaluatedFlag;
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: EvaluatedFlag = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"EvaluatedFlag", ""
) as EvaluatedFlag;
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);
}
}