1
13import { Body, Controller, Get, Inject, Param, Patch, Post, Req } from "@nestjs/common";
14import type { Request } from "express";
15import { ZodValidate } from "../../common/pipes/zod-validation.pipe.js";
16import { ScimAdminService } from "./scim-admin.service.js";
17import { ScimAdminUpdateSchema, ScimEnableSchema, ScimTestSchema, type ScimAdminUpdate } from "./schemas.js";
18
19@Controller("orgs/:orgId/scim")
20export class ScimAdminController {
21 constructor(@Inject(ScimAdminService) private readonly scim: ScimAdminService) {}
22
23 @Get()
24 get(@Param("orgId") orgId: string, @Req() req: Request) {
25 return this.scim.get(orgId, req);
26 }
27
28 @Post()
29 enable(@Param("orgId") orgId: string, @Body(ZodValidate(ScimEnableSchema)) body: Parameters<ScimAdminService["enable"]>[1], @Req() req: Request) {
30 return this.scim.enable(orgId, body, req);
31 }
32
33 @Patch()
34 update(@Param("orgId") orgId: string, @Body(ZodValidate(ScimAdminUpdateSchema)) body: ScimAdminUpdate, @Req() req: Request) {
35 return this.scim.update(orgId, body, req);
36 }
37
38 @Post("test")
39 test(@Param("orgId") orgId: string, @Body(ZodValidate(ScimTestSchema)) body: { token: string }, @Req() req: Request) {
40 return this.scim.test(orgId, body.token, req);
41 }
42}
43