@@ -647,3 +647,142 @@ def delete_annotation(self, annotation_id: str) -> None:
647647 """
648648 endpoint = "annotations/" + annotation_id
649649 self .api .delete_request (endpoint )
650+
651+ # Project
652+
653+ def find_project (self , project_id : str ) -> dict :
654+ """
655+ Find a project.
656+ """
657+ endpoint = "projects/" + project_id
658+ return self .api .get_request (endpoint )
659+
660+ def find_project_by_slug (self , slug : str ) -> dict :
661+ """
662+ Find a project by slug.
663+
664+ slug is slug of your project. (Required)
665+ """
666+ projects = self .get_projects (slug = slug )
667+ if not projects :
668+ return None
669+ return projects [0 ]
670+
671+ def get_projects (
672+ self ,
673+ slug : str = None ,
674+ offset : int = None ,
675+ limit : int = 100 ,
676+ ) -> list :
677+ """
678+ Returns a list of projects.
679+ Returns up to 1000 at a time, to get more, set offset as the starting position to fetch.
680+
681+ slug is slug of your project. (Optional)
682+ offset is the starting position number to fetch. (Optional)
683+ limit is the max number to fetch. (Optional)
684+ """
685+ if limit > 1000 :
686+ raise FastLabelInvalidException (
687+ "Limit must be less than or equal to 1000." , 422 )
688+ endpoint = "projects"
689+ params = {}
690+ if slug :
691+ params ["slug" ] = slug
692+ if offset :
693+ params ["offset" ] = offset
694+ if limit :
695+ params ["limit" ] = limit
696+ return self .api .get_request (endpoint , params = params )
697+
698+ def get_project_id_slug_map (
699+ self ,
700+ offset : int = None ,
701+ limit : int = 1000 ,
702+ ) -> dict :
703+ """
704+ Returns a map of project ids and slugs.
705+ e.g.) {
706+ "88e74507-07b5-4607-a130-cb6316ca872c", "image-bbox-slug",
707+ "fe2c24a4-8270-46eb-9c78-bb7281c8bdgs", "image-video-slug"
708+ }
709+ Returns up to 1000 at a time, to get more, set offset as the starting position to fetch.
710+
711+ offset is the starting position number to fetch. (Optional)
712+ limit is the max number to fetch. (Optional)
713+ """
714+ if limit > 1000 :
715+ raise FastLabelInvalidException (
716+ "Limit must be less than or equal to 1000." , 422 )
717+ endpoint = "projects/map/id-slug"
718+ params = {}
719+ if offset :
720+ params ["offset" ] = offset
721+ if limit :
722+ params ["limit" ] = limit
723+ return self .api .get_request (endpoint , params = params )
724+
725+ def create_project (
726+ self ,
727+ type : str ,
728+ name : str ,
729+ slug : str ,
730+ is_bitmap : bool = False ,
731+ job_size : int = 10 ,
732+ use_annotation_service : bool = False
733+ ) -> str :
734+ """
735+ Create a project.
736+
737+ type can be 'image_bbox', 'image_polygon', 'image_keypoint', 'image_line', 'image_segmentation', 'image_classification', 'image_all', 'multi_image_bbox', 'multi_image_polygon', 'multi_image_keypoint', 'multi_image_line', 'multi_image_segmentation', 'video_bbox', 'video_single_classification'. (Required)
738+ name is name of your project. (Required)
739+ slug is slug of your project. (Required)
740+ is_bitmap is whether to be annotated by pixel. (Optional)
741+ job_size is the number of tasks the annotator gets at one time. (Optional)
742+ use_annotation_service is whether to request FastLabel to provide annotation service or not. (Optional)
743+ """
744+ endpoint = "projects"
745+ payload = {
746+ "type" : type ,
747+ "name" : name ,
748+ "slug" : slug ,
749+ }
750+ if is_bitmap :
751+ payload ["isBitmap" ] = is_bitmap
752+ if job_size :
753+ payload ["jobSize" ] = job_size
754+ if use_annotation_service :
755+ payload ["useAnnotationService" ] = use_annotation_service
756+ return self .api .post_request (endpoint , payload = payload )
757+
758+ def update_project (
759+ self ,
760+ project_id : str ,
761+ name : str = None ,
762+ slug : str = None ,
763+ job_size : int = None ,
764+ ) -> str :
765+ """
766+ Update a project.
767+
768+ project_id is an id of the project. (Required)
769+ name is name of your project. (Optional)
770+ slug is slug of your project. (Optional)
771+ job_size is the number of tasks the annotator gets at one time. (Optional)
772+ """
773+ endpoint = "projects/" + project_id
774+ payload = {}
775+ if name :
776+ payload ["name" ] = name
777+ if slug :
778+ payload ["slug" ] = slug
779+ if job_size :
780+ payload ["jobSize" ] = job_size
781+ return self .api .put_request (endpoint , payload = payload )
782+
783+ def delete_project (self , project_id : str ) -> None :
784+ """
785+ Delete a project.
786+ """
787+ endpoint = "projects/" + project_id
788+ self .api .delete_request (endpoint )
0 commit comments