Revision dc7ecb7f kamaki/cli/commands/astakos.py

b/kamaki/cli/commands/astakos.py
626 626
    """List all projects"""
627 627

  
628 628
    arguments = dict(
629
        details=FlagArgument('Show details', ('-l', '--details')),
629 630
        name=ValueArgument('Filter by name', ('--with-name', )),
630 631
        state=ValueArgument('Filter by state', ('--with-state', )),
631 632
        owner=ValueArgument('Filter by owner', ('--with-owner', ))
......
634 635
    @errors.generic.all
635 636
    @errors.user.astakosclient
636 637
    def _run(self):
637
        self._print(self.client.get_projects(
638
            self['name'], self['state'], self['owner']))
638
        r = self.client.get_projects(
639
            self['name'], self['state'], self['owner'])
640
        if not (self['details'] or self['output_format']):
641
            r = [dict(
642
                id=i['id'],
643
                name=i['name'],
644
                description=i['description']) for i in r]
645
        self._print(r)
639 646

  
640 647
    def main(self):
641 648
        super(self.__class__, self)._run()
......
720 727

  
721 728
    action = ''
722 729

  
730
    arguments = dict(
731
        reason=ValueArgument('Quote a reason for this action', '--reason'),
732
    )
733

  
723 734
    @errors.generic.all
724 735
    @errors.user.astakosclient
725 736
    def _run(self, project_id, quote_a_reason):
726 737
        self.client.project_action(project_id, self.action, quote_a_reason)
727 738

  
728
    def main(self, project_id, quote_a_reason=''):
739
    def main(self, project_id):
729 740
        super(_project_action, self)._run()
730
        self._run(project_id, quote_a_reason)
741
        self._run(project_id, self['reason'] or '')
731 742

  
732 743

  
733 744
@command(project_commands)
......
754 765
    action = 'reinstate'
755 766

  
756 767

  
757
@command(project_commands)
758
class project_application(_init_synnefo_astakosclient):
759
    """Application management commands"""
760

  
768
class _application_action(_init_synnefo_astakosclient):
761 769

  
762
@command(project_commands)
763
class project_application_list(_init_synnefo_astakosclient, _optional_json):
764
    """List all applications (old and new)"""
770
    action = ''
765 771

  
766 772
    arguments = dict(
767
        project=IntArgument('Filter by project id', '--with-project-id')
773
        app_id=ValueArgument('The application ID', '--app-id'),
774
        reason=ValueArgument('Quote a reason for this action', '--reason'),
768 775
    )
776
    required = ('app_id', )
769 777

  
770 778
    @errors.generic.all
771 779
    @errors.user.astakosclient
772
    def _run(self):
773
        self._print(self.client.get_applications(self['project']))
774

  
775
    def main(self):
776
        super(self.__class__, self)._run()
777
        self._run()
778

  
779

  
780
@command(project_commands)
781
class project_application_info(_init_synnefo_astakosclient, _optional_json):
782
    """Get details on an application"""
783

  
784
    @errors.generic.all
785
    @errors.user.astakosclient
786
    def _run(self, app_id):
787
        self._print(
788
            self.client.get_application(app_id), self.print_dict)
789

  
790
    def main(self, application_id):
791
        super(self.__class__, self)._run()
792
        self._run(application_id)
793

  
780
    def _run(self, project_id, app_id, quote_a_reason):
781
        self.client.application_action(
782
            project_id, app_id, self.action, quote_a_reason)
794 783

  
795
class _application_action(_init_synnefo_astakosclient):
796

  
797
    action = ''
798

  
799
    @errors.generic.all
800
    @errors.user.astakosclient
801
    def _run(self, app_id, quote_a_reason):
802
        self.client.application_action(app_id, self.action, quote_a_reason)
803

  
804
    def main(self, application_id, quote_a_reason=''):
784
    def main(self, project_id):
805 785
        super(_application_action, self)._run()
806
        self._run(application_id, quote_a_reason)
786
        self._run(self['app_id'], self['reason'] or '')
807 787

  
808 788

  
809 789
@command(project_commands)
810
class project_application_approve(_application_action):
790
class project_approve(_application_action):
811 791
    """Approve an application (special privileges needed)"""
812 792
    action = 'approve'
813 793

  
814 794

  
815 795
@command(project_commands)
816
class project_application_deny(_application_action):
796
class project_deny(_application_action):
817 797
    """Deny an application (special privileges needed)"""
818 798
    action = 'deny'
819 799

  
820 800

  
821 801
@command(project_commands)
822
class project_application_dismiss(_application_action):
802
class project_dismiss(_application_action):
823 803
    """Dismiss your denied application"""
824 804
    action = 'dismiss'
825 805

  
826 806

  
827 807
@command(project_commands)
828
class project_application_cancel(_application_action):
808
class project_cancel(_application_action):
829 809
    """Cancel your application"""
830 810
    action = 'cancel'
831 811

  

Also available in: Unified diff