313 lines
6.6 KiB
TypeScript
313 lines
6.6 KiB
TypeScript
/**
|
|
* Interface of the server (auto-generated code)
|
|
*/
|
|
import {
|
|
HTTPMimeType,
|
|
HTTPRequestModel,
|
|
RESTConfig,
|
|
RESTRequestJson,
|
|
RESTRequestVoid,
|
|
} from "../rest-tools";
|
|
|
|
import { z as zod } from "zod"
|
|
import {
|
|
AddUserDataWrite,
|
|
Application,
|
|
ApplicationSmall,
|
|
ApplicationWrite,
|
|
ClientToken,
|
|
Long,
|
|
RightDescription,
|
|
ZodApplication,
|
|
ZodApplicationSmall,
|
|
ZodLong,
|
|
ZodRightDescription,
|
|
isApplication,
|
|
isClientToken,
|
|
} from "../model";
|
|
|
|
export namespace ApplicationResource {
|
|
|
|
export function addUser({
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
data: AddUserDataWrite,
|
|
}): Promise<void> {
|
|
return RESTRequestVoid({
|
|
restModel: {
|
|
endPoint: "/application/{id}/users",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
});
|
|
};
|
|
export function create({
|
|
restConfig,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
data: ApplicationWrite,
|
|
}): Promise<Application> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/application/",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
data,
|
|
}, isApplication);
|
|
};
|
|
export function get({
|
|
restConfig,
|
|
params,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
}): Promise<Application> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/application/{id}",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, isApplication);
|
|
};
|
|
|
|
export const ZodGetApplicationUsersTypeReturn = zod.array(ZodLong);
|
|
export type GetApplicationUsersTypeReturn = zod.infer<typeof ZodGetApplicationUsersTypeReturn>;
|
|
|
|
export function isGetApplicationUsersTypeReturn(data: any): data is GetApplicationUsersTypeReturn {
|
|
try {
|
|
ZodGetApplicationUsersTypeReturn.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodGetApplicationUsersTypeReturn' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function getApplicationUsers({
|
|
restConfig,
|
|
params,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
}): Promise<GetApplicationUsersTypeReturn> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/application/{id}/users",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, isGetApplicationUsersTypeReturn);
|
|
};
|
|
|
|
export const ZodGetApplicationsSmallTypeReturn = zod.array(ZodApplicationSmall);
|
|
export type GetApplicationsSmallTypeReturn = zod.infer<typeof ZodGetApplicationsSmallTypeReturn>;
|
|
|
|
export function isGetApplicationsSmallTypeReturn(data: any): data is GetApplicationsSmallTypeReturn {
|
|
try {
|
|
ZodGetApplicationsSmallTypeReturn.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodGetApplicationsSmallTypeReturn' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function getApplicationsSmall({
|
|
restConfig,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
}): Promise<GetApplicationsSmallTypeReturn> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/application/small",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
}, isGetApplicationsSmallTypeReturn);
|
|
};
|
|
export function getClientToken({
|
|
restConfig,
|
|
queries,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
queries: {
|
|
application?: string,
|
|
},
|
|
}): Promise<ClientToken> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/application/get_token",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
queries,
|
|
}, isClientToken);
|
|
};
|
|
|
|
export const ZodGetRightsDescriptionTypeReturn = zod.array(ZodRightDescription);
|
|
export type GetRightsDescriptionTypeReturn = zod.infer<typeof ZodGetRightsDescriptionTypeReturn>;
|
|
|
|
export function isGetRightsDescriptionTypeReturn(data: any): data is GetRightsDescriptionTypeReturn {
|
|
try {
|
|
ZodGetRightsDescriptionTypeReturn.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodGetRightsDescriptionTypeReturn' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function getRightsDescription({
|
|
restConfig,
|
|
params,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
}): Promise<GetRightsDescriptionTypeReturn> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/application/{id}/rights",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, isGetRightsDescriptionTypeReturn);
|
|
};
|
|
|
|
export const ZodGetsTypeReturn = zod.array(ZodApplication);
|
|
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
|
|
|
export function isGetsTypeReturn(data: any): data is GetsTypeReturn {
|
|
try {
|
|
ZodGetsTypeReturn.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodGetsTypeReturn' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function gets({
|
|
restConfig,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
}): Promise<GetsTypeReturn> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/application/",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
}, isGetsTypeReturn);
|
|
};
|
|
export function logOut({
|
|
restConfig,
|
|
queries,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
queries: {
|
|
application?: string,
|
|
},
|
|
}): Promise<string> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/application/return",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
queries,
|
|
});
|
|
};
|
|
export function patch({
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
data: ApplicationWrite,
|
|
}): Promise<Application> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/application/{id}",
|
|
requestType: HTTPRequestModel.PATCH,
|
|
contentType: HTTPMimeType.JSON,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}, isApplication);
|
|
};
|
|
export function remove({
|
|
restConfig,
|
|
params,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
}): Promise<void> {
|
|
return RESTRequestVoid({
|
|
restModel: {
|
|
endPoint: "/application/{id}",
|
|
requestType: HTTPRequestModel.DELETE,
|
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
},
|
|
restConfig,
|
|
params,
|
|
});
|
|
};
|
|
export function removeUser({
|
|
restConfig,
|
|
params,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
userId: Long,
|
|
},
|
|
}): Promise<void> {
|
|
return RESTRequestVoid({
|
|
restModel: {
|
|
endPoint: "/application/{id}/users/${userId}",
|
|
requestType: HTTPRequestModel.DELETE,
|
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
},
|
|
restConfig,
|
|
params,
|
|
});
|
|
};
|
|
}
|