Пример #1
0
class ThreadFixCreate(object):
    def __init__(self, team_id, team, application, url):
        self.helper = ThreadFixHelper()
        self._create_application_wrapper(team_id, team, application, url)

    def _create_application_wrapper(self, team_id, team, application, url):
        if not team_id and not team:
            threadfixloghelper.log_error_specify_team()
            return
        if team and not team_id:
            team_id = self._get_team_id_by_name(team)
        if team_id is None:
            threadfixloghelper.log_error_no_team_with_application(team)
            return
        created_app = self._create_application(team_id, application, url)
        threadfixloghelper.log_info_application_created_with_id((created_app['id']))

    def _create_application(self, team_id, name, url):
        response = self.helper.api.create_application(team_id, name, url)
        APIHelper().check_for_response_errors(response)
        return response.data

    def _get_team_id_by_name(self, team_name):
            teams = self.helper.get_team_list()
            for team in teams:
                if team['name'] == team_name:
                    return team['id']
            return None
Пример #2
0
class ThreadFixTeams(object):
    def __init__(self):
        self.helper = ThreadFixHelper()
        self._list_teams()

    def _list_teams(self):
        teams = self.helper.get_team_list()
        if teams:
            print("{0:^10} {1:30}".format('ID', 'Name'))
            print("{0:10} {1:30}".format('-' * 10, '-' * 30))
            for team in teams:
                print("{0:^10} {1:30}".format(team['id'], team['name']))
            threadfixloghelper.log_info_threadfix_teams_listed_success()
            print('\n\n')
        else:
            threadfixloghelper.log_error_no_team()