File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -365,6 +365,23 @@ def delete_project(ctx: Context, project_id):
365365 log (f'Deleted project "{ project_id } ".' )
366366
367367
368+ @cli .command ()
369+ @click .argument ("project_id" )
370+ @click .argument ("local_filename" , type = click .Path (exists = True ))
371+ @click .pass_context
372+ def upload_project_thumbnail (
373+ ctx : Context , project_id : str , local_filename : str
374+ ) -> None :
375+ """Upload a project thumbnail."""
376+
377+ response = ctx .obj ["client" ].upload_project_thumbnail (project_id , local_filename )
378+
379+ if ctx .obj ["format_json" ]:
380+ print_json (response )
381+ else :
382+ log (f'Uploaded thumbnail "{ local_filename } " to project "{ project_id } ".' )
383+
384+
368385@cli .command ()
369386@click .argument ("project_id" )
370387@click .argument ("project_path" )
Original file line number Diff line number Diff line change @@ -603,6 +603,41 @@ def patch_project(
603603
604604 return resp .json ()
605605
606+ def upload_project_thumbnail (
607+ self ,
608+ project_id : str ,
609+ local_filename : str ,
610+ ) -> requests .Response :
611+ """Upload a project thumbnail.
612+
613+ Args:
614+ project_id: Project ID.
615+ local_filename: Path to the thumbnail image file.
616+
617+ Raises:
618+ pathvalidate.ValidationError: Raised when the uploaded file does not have a valid filename.
619+
620+ Returns:
621+ The response object from the upload request.
622+
623+ Example:
624+ ```python
625+ client.upload_project_thumbnail(
626+ project_id="123e4567-e89b-12d3-a456-426614174000",
627+ local_filename="thumbnail.png"
628+ )
629+ ```
630+ """
631+ # if the filepath is invalid, it will throw a new error `pathvalidate.ValidationError`
632+ is_valid_filepath (local_filename )
633+
634+ with open (local_filename , "rb" ) as thumbnail :
635+ return self ._request (
636+ "POST" ,
637+ f"projects/{ project_id } /thumbnail" ,
638+ files = {"thumbnail" : thumbnail },
639+ )
640+
606641 def upload_files (
607642 self ,
608643 project_id : str ,
You can’t perform that action at this time.
0 commit comments