File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 33from enapter import cli
44
55from .blueprint_download_command import BlueprintDownloadCommand
6+ from .blueprint_get_command import BlueprintGetCommand
67from .blueprint_upload_command import BlueprintUploadCommand
78from .blueprint_validate_command import BlueprintValidateCommand
89
@@ -17,6 +18,7 @@ def register(parent: cli.Subparsers) -> None:
1718 subparsers = parser .add_subparsers (dest = "blueprint_command" , required = True )
1819 for command in [
1920 BlueprintDownloadCommand ,
21+ BlueprintGetCommand ,
2022 BlueprintUploadCommand ,
2123 BlueprintValidateCommand ,
2224 ]:
@@ -27,6 +29,8 @@ async def run(args: argparse.Namespace) -> None:
2729 match args .blueprint_command :
2830 case "download" :
2931 await BlueprintDownloadCommand .run (args )
32+ case "get" :
33+ await BlueprintGetCommand .run (args )
3034 case "upload" :
3135 await BlueprintUploadCommand .run (args )
3236 case "validate" :
Original file line number Diff line number Diff line change 1+ import argparse
2+ import json
3+ import logging
4+
5+ from enapter import cli , http
6+
7+ LOGGER = logging .getLogger (__name__ )
8+
9+
10+ class BlueprintGetCommand (cli .Command ):
11+
12+ @staticmethod
13+ def register (parent : cli .Subparsers ) -> None :
14+ parser = parent .add_parser (
15+ "get" , formatter_class = argparse .ArgumentDefaultsHelpFormatter
16+ )
17+ parser .add_argument ("id" , help = "ID of the blueprint to get" )
18+
19+ @staticmethod
20+ async def run (args : argparse .Namespace ) -> None :
21+ async with http .api .Client (http .api .Config .from_env ()) as client :
22+ blueprint = await client .blueprints .get (blueprint_id = args .id )
23+ print (json .dumps (blueprint .to_dto ()))
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ class Client:
1414 def __init__ (self , client : httpx .AsyncClient ) -> None :
1515 self ._client = client
1616
17+ async def get (self , blueprint_id : str ) -> Blueprint :
18+ url = f"v3/blueprints/{ blueprint_id } "
19+ response = await self ._client .get (url )
20+ api .check_error (response )
21+ return Blueprint .from_dto (response .json ()["blueprint" ])
22+
1723 async def upload_file (self , path : pathlib .Path ) -> Blueprint :
1824 with path .open ("rb" ) as file :
1925 data = file .read ()
You can’t perform that action at this time.
0 commit comments