(self, args, **kwargs)
| 578 | |
| 579 | @add_auth_token_to_kwargs_from_cli |
| 580 | def run(self, args, **kwargs): |
| 581 | resource_id = getattr(args, self.pk_argument_name, None) |
| 582 | instance = self.get_resource(resource_id, **kwargs) |
| 583 | data = load_meta_file(args.file) |
| 584 | modified_instance = self.resource.deserialize(data) |
| 585 | |
| 586 | if not getattr(modified_instance, "id", None): |
| 587 | modified_instance.id = instance.id |
| 588 | else: |
| 589 | if modified_instance.id != instance.id: |
| 590 | raise Exception( |
| 591 | "The value for the %s id in the JSON/YAML file " |
| 592 | "does not match the ID provided in the " |
| 593 | "command line arguments." % self.resource.get_display_name().lower() |
| 594 | ) |
| 595 | return self.manager.update(modified_instance, **kwargs) |
| 596 | |
| 597 | def run_and_print(self, args, **kwargs): |
| 598 | instance = self.run(args, **kwargs) |
no test coverage detected