@@ -914,18 +914,17 @@ async def {name}(
914914 ]
915915 )
916916 elif procedure .type == "upload" :
917- assert input_meta
918917 assert output_meta
919918 assert error_meta
920- _ , input_type , render_input_method = input_meta
921919 _ , output_type , parse_output_method = output_meta
922920 _ , error_type , parse_error_method = error_meta
923921 error_type_name = extract_inner_type (error_type )
924922
925923 output_or_error_type = UnionTypeExpr ([output_type , error_type_name ])
926924
927- if init_meta :
925+ if init_meta and input_meta :
928926 _ , init_type , render_init_method = init_meta
927+ _ , input_type , render_input_method = input_meta
929928 current_chunks .extend (
930929 [
931930 reindent (
@@ -950,8 +949,9 @@ async def {name}(
950949 )
951950 ]
952951 )
953- else :
954- assert protocol_version == "v1.1" , "Protocol v2 requires init to be defined"
952+ elif protocol_version == "v1.1" :
953+ assert input_meta , "Protocol v1 requires input to be defined"
954+ _ , input_type , render_input_method = input_meta
955955 current_chunks .extend (
956956 [
957957 reindent (
@@ -977,6 +977,36 @@ async def {name}(
977977 )
978978 ]
979979 )
980+ elif protocol_version == "v2.0" :
981+ assert init_meta , "Protocol v2 requires init to be defined"
982+ _ , init_type , render_init_method = init_meta
983+ current_chunks .extend (
984+ [
985+ reindent (
986+ " " ,
987+ f"""\
988+ async def { name } (
989+ self,
990+ init: { render_type_expr (init_type )} ,
991+ ) -> { # TODO(dstewart) This should just be output_type
992+ render_type_expr (output_or_error_type )
993+ } :
994+ return await self.client.send_upload(
995+ { repr (schema_name )} ,
996+ { repr (name )} ,
997+ init,
998+ None,
999+ { reindent (" " , render_init_method )} ,
1000+ None,
1001+ { reindent (" " , parse_output_method )} ,
1002+ { reindent (" " , parse_error_method )} ,
1003+ )
1004+ """ ,
1005+ )
1006+ ]
1007+ )
1008+ else :
1009+ raise ValueError ("Precondition failed" )
9801010 elif procedure .type == "stream" :
9811011 assert output_meta
9821012 assert error_meta
0 commit comments