model="IncidentType", query_str=query_str, page=page, items_per_page=items_per_page, sort_by=sort_by, descending=descending, fields=fields, values=values, ops=ops, ) @router.post( "/", response_model=IncidentTypeRead, dependencies=[Depends(PermissionsDependency([AdminPermission]))], ) def create_incident_type( *, db_session: Session = Depends(get_db), incident_type_in: IncidentTypeCreate, ): """ Create a new incident type. """ incident_type = create(db_session=db_session, incident_type_in=incident_type_in) return incident_type @router.put(
@router.get("/{plugin_id}", response_model=PluginRead) def get_plugin(*, db_session: Session = Depends(get_db), plugin_id: int): """ Get a plugin. """ plugin = get(db_session=db_session, plugin_id=plugin_id) if not plugin: raise HTTPException(status_code=404, detail="The plugin with this id does not exist.") return plugin @router.put( "/{plugin_id}", response_model=PluginCreate, dependencies=[Depends(PermissionsDependency([ProjectAdminPermission]))], ) def update_plugin( *, db_session: Session = Depends(get_db), plugin_id: int, plugin_in: PluginUpdate, ): """ Update a plugin. """ plugin = get(db_session=db_session, plugin_id=plugin_id) if not plugin: raise HTTPException(status_code=404, detail="The plugin with this id does not exist.")
from .service import create, get, update router = APIRouter() @router.get("", response_model=IncidentTypePagination, tags=["incident_types"]) def get_incident_types(*, common: dict = Depends(common_parameters)): """Returns all incident types.""" return search_filter_sort_paginate(model="IncidentType", **common) @router.post( "", response_model=IncidentTypeRead, dependencies=[ Depends(PermissionsDependency([SensitiveProjectActionPermission])) ], ) def create_incident_type( *, db_session: Session = Depends(get_db), incident_type_in: IncidentTypeCreate, ): """Create a new incident type.""" incident_type = create(db_session=db_session, incident_type_in=incident_type_in) return incident_type @router.put( "/{incident_type_id}",
UserUpdate, UserPagination, UserLoginResponse, UserRegisterResponse, ) from .service import get, get_by_email, update, create, get_current_user auth_router = APIRouter() user_router = APIRouter() @user_router.get( "", dependencies=[ Depends(PermissionsDependency([ OrganizationMemberPermission, ])) ], response_model=UserPagination, ) def get_users(*, organization: OrganizationSlug, common: dict = Depends(common_parameters)): """Get all users.""" common["filter_spec"] = { "and": [{ "model": "Organization", "op": "==", "field": "name", "value": organization }]
*, db_session: Session = Depends(get_db), incident_cost_type_id: PrimaryKey ): """Get an incident cost type by its id.""" incident_cost_type = get(db_session=db_session, incident_cost_type_id=incident_cost_type_id) if not incident_cost_type: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail=[{"msg": "An incident cost type with this id does not exist."}], ) return incident_cost_type @router.post( "", response_model=IncidentCostTypeRead, dependencies=[Depends(PermissionsDependency([SensitiveProjectActionPermission]))], ) def create_incident_cost_type( *, db_session: Session = Depends(get_db), incident_cost_type_in: IncidentCostTypeCreate ): """Create an incident cost type.""" incident_cost_type = create(db_session=db_session, incident_cost_type_in=incident_cost_type_in) return incident_cost_type @router.put( "/{incident_cost_type_id}", response_model=IncidentCostTypeRead, dependencies=[Depends(PermissionsDependency([SensitiveProjectActionPermission]))], ) def update_incident_cost_type(
model="Organization", query_str=query_str, page=page, items_per_page=items_per_page, sort_by=sort_by, descending=descending, fields=fields, values=values, ops=ops, ) @router.post( "/", response_model=OrganizationRead, dependencies=[Depends(PermissionsDependency([OrganizationOwnerPermission]))], ) def create_organization( *, db_session: Session = Depends(get_db), organization_in: OrganizationCreate ): """ Create a new organization. """ organization = get_by_name(db_session=db_session, name=organization_in.name) if organization: raise HTTPException( status_code=400, detail="The organization with this name already exists." ) organization = create(db_session=db_session, organization_in=organization_in) return organization
from .service import create, delete, get, get_by_name, update router = APIRouter() @router.get("", response_model=ProjectPagination) def get_projects(common: dict = Depends(common_parameters)): """Get all projects.""" return search_filter_sort_paginate(model="Project", **common) @router.post( "", response_model=ProjectRead, summary="Create a new project.", dependencies=[Depends(PermissionsDependency([ProjectCreatePermission]))], ) def create_project(*, db_session: Session = Depends(get_db), project_in: ProjectCreate): """Create a new project.""" project = get_by_name(db_session=db_session, name=project_in.name) if project: raise ValidationError( [ ErrorWrapper(ExistsError( msg="A project with this name already exists."), loc="name") ], model=ProjectCreate, )
include_fields = { "items": {"__all__": include_sets}, "itemsPerPage": ..., "page": ..., "total": ..., } return json.loads(IncidentPagination(**pagination).json(include=include_fields)) return json.loads(IncidentPagination(**pagination).json()) @router.get( "/{incident_id}", response_model=IncidentRead, summary="Retrieve a single incident.", dependencies=[Depends(PermissionsDependency([IncidentViewPermission]))], ) def get_incident( *, incident_id: PrimaryKey, db_session: Session = Depends(get_db), current_incident: Incident = Depends(get_current_incident), ): """Retrieve details about a specific incident.""" return current_incident @router.post("", response_model=IncidentRead, summary="Create a new incident.") def create_incident( *, db_session: Session = Depends(get_db),