Skip to content

Commit

Permalink
Merge pull request #23 from scality/improvement/SCUBA-177/admin-api-t…
Browse files Browse the repository at this point in the history
…ests

SCUBA-177: Admin API improvements
  • Loading branch information
dvasilas authored Nov 13, 2024
2 parents 2a1d97b + 813430d commit 71a7252
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
28 changes: 14 additions & 14 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,21 @@ export const ScubaApiAxiosParamCreator = function (configuration?: Configuration
/**
*
* @param {AdminActions} action
* @param {string} recordLog
* @param {string} sessionId
* @param {any} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
admin: async (
action: AdminActions,
recordLog: string,
sessionId: string,
body?: any,
options: AxiosRequestConfig = {},
): Promise<RequestArgs> => {
// verify required parameter 'action' is not null or undefined
assertParamExists('admin', 'action', action);
// verify required parameter 'recordLog' is not null or undefined
assertParamExists('admin', 'recordLog', recordLog);
// verify required parameter 'sessionId' is not null or undefined
assertParamExists('admin', 'sessionId', sessionId);

const localVarPath = '/admin';
// use dummy base URL string because the URL constructor only accepts absolute URLs.
Expand All @@ -215,7 +215,7 @@ export const ScubaApiAxiosParamCreator = function (configuration?: Configuration

const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options };
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = { action, recordLog } as any;
const localVarQueryParameter = { action, sessionId } as any;

localVarHeaderParameter['Content-Type'] = 'application/json';

Expand Down Expand Up @@ -303,18 +303,18 @@ export const ScubaApiFp = function (configuration?: Configuration) {
/**
*
* @param {AdminActions} action
* @param {string} recordLog
* @param {string} sessionId
* @param {any} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async admin(
action: AdminActions,
recordLog: string,
sessionId: string,
body?: any,
options?: AxiosRequestConfig,
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.admin(action, recordLog, body, options);
const localVarAxiosArgs = await localVarAxiosParamCreator.admin(action, sessionId, body, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
};
Expand Down Expand Up @@ -363,13 +363,13 @@ export const ScubaApiFactory = function (configuration?: Configuration, basePath
/**
*
* @param {AdminActions} action
* @param {string} recordLog
* @param {string} sessionId
* @param {any} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
admin(action: AdminActions, recordLog: string, body?: any, options?: any): AxiosPromise<void> {
return localVarFp.admin(action, recordLog, body, options).then(request => request(axios, basePath));
admin(action: AdminActions, sessionId: string, body?: any, options?: any): AxiosPromise<void> {
return localVarFp.admin(action, sessionId, body, options).then(request => request(axios, basePath));
},
};
};
Expand Down Expand Up @@ -433,14 +433,14 @@ export class ScubaApi extends BaseAPI {
/**
*
* @param {AdminActions} action
* @param {string} recordLog
* @param {string} sessionId
* @param {any} [body]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public admin(action: AdminActions, recordLog: string, body?: any, options?: AxiosRequestConfig) {
public admin(action: AdminActions, sessionId: string, body?: any, options?: AxiosRequestConfig) {
return ScubaApiFp(this.configuration)
.admin(action, recordLog, body, options)
.admin(action, sessionId, body, options)
.then(request => request(this.axios, this.basePath));
}
}
14 changes: 12 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export type HealthCheckResponse = {
date?: string;
};

export type AdminResponseCseq = {
sessionId: string;
cseq: number;
};

function lpad(num: number, digits: number) {
return num.toString().padStart(digits, '0');
}
Expand Down Expand Up @@ -170,8 +175,13 @@ export default class ScubaClient {
return resp.data;
}

async admin(action: AdminActions, recordLog: string, options?: AxiosRequestConfig, body?: any): Promise<void> {
const resp = (await this._api.admin(action, recordLog, body, {
async admin(
action: AdminActions,
sessionId: string,
options?: AxiosRequestConfig,
body?: any,
): Promise<AdminResponseCseq | void> {
const resp = (await this._api.admin(action, sessionId, body, {
...this._defaultReqOptions,
...options,
})) as any;
Expand Down

0 comments on commit 71a7252

Please sign in to comment.