66from command .model .configuration import CMDCommandGroup , CMDCommand , CMDHttpOperation , CMDHttpRequest , \
77 CMDSchemaDefault , CMDHttpResponseJsonBody , CMDArrayOutput , CMDJsonInstanceUpdateAction , \
88 CMDInstanceUpdateOperation , CMDRequestJson , DEFAULT_CONFIRMATION_PROMPT , CMDClsSchemaBase , CMDHttpResponse , \
9- CMDResponseJson , CMDResource
9+ CMDResponseJson , CMDResource , CMDHttpRequestBinaryBody
1010from swagger .model .schema .cmd_builder import CMDBuilder
1111from swagger .model .schema .fields import MutabilityEnum
1212from swagger .model .schema .path_item import PathItem
@@ -404,10 +404,13 @@ def create_draft_command_group(self, resource,
404404 delete_command .confirmation = DEFAULT_CONFIRMATION_PROMPT # add confirmation for delete command by default
405405 command_group .commands .append (delete_command )
406406
407+ skip_update = False
407408 if path_item .put is not None and 'put' in methods :
408409 cmd_builder = CMDBuilder (path = resource .path , method = 'put' , mutability = MutabilityEnum .Create ,
409410 parameterized_host = parameterized_host )
410411 op = self .generate_operation (cmd_builder , path_item , instance_var )
412+ if isinstance (op .http .request .body , CMDHttpRequestBinaryBody ):
413+ skip_update = True
411414 create_command = self .generate_command (path_item , resource , instance_var , cmd_builder , op )
412415 command_group .commands .append (create_command )
413416
@@ -426,29 +429,30 @@ def create_draft_command_group(self, resource,
426429 command_group .commands .append (head_command )
427430
428431 # update command
429- if update_by is None :
430- update_by_patch_command = None
431- update_by_generic_command = None
432- if path_item .patch is not None and 'patch' in methods :
433- cmd_builder = CMDBuilder (path = resource .path , method = 'patch' , mutability = MutabilityEnum .Update ,
434- parameterized_host = parameterized_host )
435- op = self .generate_operation (cmd_builder , path_item , instance_var )
436- update_by_patch_command = self .generate_command (path_item , resource , instance_var , cmd_builder , op )
437- if path_item .get is not None and path_item .put is not None and 'get' in methods and 'put' in methods :
438- cmd_builder = CMDBuilder (path = resource .path ,
439- parameterized_host = parameterized_host )
440- get_op = self .generate_operation (
441- cmd_builder , path_item , instance_var , method = 'get' , mutability = MutabilityEnum .Read )
442- put_op = self .generate_operation (
443- cmd_builder , path_item , instance_var , method = 'put' , mutability = MutabilityEnum .Update )
444- update_by_generic_command = self .generate_generic_update_command (path_item , resource , instance_var , cmd_builder , get_op , put_op )
445- # generic update command first, patch update command after that
446- if update_by_generic_command :
447- command_group .commands .append (update_by_generic_command )
448- elif update_by_patch_command :
449- command_group .commands .append (update_by_patch_command )
450- else :
451- if update_by == 'GenericOnly' :
432+ if not skip_update :
433+ if update_by is None :
434+ update_by_patch_command = None
435+ update_by_generic_command = None
436+ if path_item .patch is not None and 'patch' in methods :
437+ cmd_builder = CMDBuilder (path = resource .path , method = 'patch' , mutability = MutabilityEnum .Update ,
438+ parameterized_host = parameterized_host )
439+ op = self .generate_operation (cmd_builder , path_item , instance_var )
440+ update_by_patch_command = self .generate_command (path_item , resource , instance_var , cmd_builder , op )
441+ if path_item .get is not None and path_item .put is not None and 'get' in methods and 'put' in methods :
442+ cmd_builder = CMDBuilder (path = resource .path ,
443+ parameterized_host = parameterized_host )
444+ get_op = self .generate_operation (
445+ cmd_builder , path_item , instance_var , method = 'get' , mutability = MutabilityEnum .Read )
446+ put_op = self .generate_operation (
447+ cmd_builder , path_item , instance_var , method = 'put' , mutability = MutabilityEnum .Update )
448+ update_by_generic_command = self .generate_generic_update_command (path_item , resource , instance_var ,
449+ cmd_builder , get_op , put_op )
450+ # generic update command first, patch update command after that
451+ if update_by_generic_command :
452+ command_group .commands .append (update_by_generic_command )
453+ elif update_by_patch_command :
454+ command_group .commands .append (update_by_patch_command )
455+ elif update_by == 'GenericOnly' :
452456 if path_item .get is None or path_item .put is None :
453457 raise exceptions .InvalidAPIUsage (f"Invalid update_by resource: resource needs to have 'get' and 'put' operations: '{ resource } '" )
454458 if 'get' not in methods or 'put' not in methods :
0 commit comments