sdcclient/_common.py
def edit_team(self, name, memberships=None, filter=None, description=None, show=None, theme=None,
                  perm_capture=None, perm_custom_events=None, perm_aws_data=None):
        '''
        **Description**
           Edits an existing team. All arguments are optional. Team settings for any arguments unspecified will remain at their current settings.

        **Arguments**
            - **name**: the name of the team to edit.
            - **memberships**: dictionary of (user-name, team-role) pairs that should describe new memberships of the team.
            - **filter**: the scope that this team is able to access within Sysdig Monitor.
            - **description**: describes the team that will be created.
            - **show**: possible values are *host*, *container*.
            - **theme**: the color theme that Sysdig Monitor will use when displaying the team.
            - **perm_capture**: if True, this team will be allowed to take sysdig captures.
            - **perm_custom_events**: if True, this team will be allowed to view all custom events from every user and agent.
            - **perm_aws_data**: if True, this team will have access to all AWS metrics and tags, regardless of the team's scope.

        **Success Return Value**
            The edited team.

        **Example**
            `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_
        '''
        res = self.get_team(name)
        if res[0] == False:
            return res

        t = res[1]
        reqbody = {
            'name': name,
            'theme': theme if theme else t['theme'],
            'show': show if show else t['show'],
            'canUseSysdigCapture': perm_capture if perm_capture else t['canUseSysdigCapture'],
            'canUseCustomEvents': perm_custom_events if perm_custom_events else t['canUseCustomEvents'],
            'canUseAwsMetrics': perm_aws_data if perm_aws_data else t['canUseAwsMetrics'],
            'id': t['id'],
            'version': t['version']
        }

        # Handling team description
        if description is not None:
            reqbody['description'] = description
        elif 'description' in list(t.keys()):
            reqbody['description'] = t['description']

        # Handling for users to map (user-name, team-role) pairs to memberships
        if memberships != None:
            res = self._get_user_id_dict(list(memberships.keys()))
            if res[0] == False:
                return [False, 'Could not convert user names to IDs']
            reqbody['userRoles'] = [
                {
                    'userId': user_id,
                    'role': memberships[user_name]
                }
                for (user_name, user_id) in res[1].items()
            ]
        elif 'userRoles' in list(t.keys()):
            reqbody['userRoles'] = t['userRoles']
        else:
            reqbody['userRoles'] = []

        # Special handling for filters since we don't support blank filters
        if filter != None:
            reqbody['filter'] = filter
        elif 'filter' in list(t.keys()):
            reqbody['filter'] = t['filter']

        res = requests.put(self.url + '/api/teams/' + str(t['id']), headers=self.hdrs, data=json.dumps(reqbody), verify=self.ssl_verify)
        return self._request_result(res)
def edit_team(self, name, memberships=None, filter=None, description=None, show=None, theme=None,
                  perm_capture=None, perm_custom_events=None, perm_aws_data=None):
        '''
        **Description**
           Edits an existing team. All arguments are optional. Team settings for any arguments unspecified will remain at their current settings.

        **Arguments**
            - **name**: the name of the team to edit.
            - **memberships**: dictionary of (user-name, team-role) pairs that should describe new memberships of the team.
            - **filter**: the scope that this team is able to access within Sysdig Monitor.
            - **description**: describes the team that will be created.
            - **show**: possible values are *host*, *container*.
            - **theme**: the color theme that Sysdig Monitor will use when displaying the team.
            - **perm_capture**: if True, this team will be allowed to take sysdig captures.
            - **perm_custom_events**: if True, this team will be allowed to view all custom events from every user and agent.
            - **perm_aws_data**: if True, this team will have access to all AWS metrics and tags, regardless of the team's scope.

        **Success Return Value**
            The edited team.

        **Example**
            `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_
        '''
        res = self.get_team(name)
        if res[0] == False:
            return res

        t = res[1]
        reqbody = {
            'name': name,
            'theme': theme if theme else t['theme'],
            'show': show if show else t['show'],
            'canUseSysdigCapture': perm_capture if perm_capture else t['canUseSysdigCapture'],
            'canUseCustomEvents': perm_custom_events if perm_custom_events else t['canUseCustomEvents'],
            'canUseAwsMetrics': perm_aws_data if perm_aws_data else t['canUseAwsMetrics'],
            'id': t['id'],
            'version': t['version']
        }

        # Handling team description
        if description is not None:
            reqbody['description'] = description
        elif 'description' in list(t.keys()):
            reqbody['description'] = t['description']

        # Handling for users to map (user-name, team-role) pairs to memberships
        if memberships != None:
            res = self._get_user_id_dict(list(memberships.keys()))
            if res[0] == False:
                return [False, 'Could not convert user names to IDs']
            reqbody['userRoles'] = [
                {
                    'userId': user_id,
                    'role': memberships[user_name]
                }
                for (user_name, user_id) in res[1].items()
            ]
        elif 'userRoles' in list(t.keys()):
            reqbody['userRoles'] = t['userRoles']
        else:
            reqbody['userRoles'] = []

        # Special handling for filters since we don't support blank filters
        if filter != None:
            reqbody['filter'] = filter
        elif 'filter' in list(t.keys()):
            reqbody['filter'] = t['filter']

        res = requests.put(self.url + '/api/teams/' + str(t['id']), headers=self.hdrs, data=json.dumps(reqbody), verify=self.ssl_verify)
        return self._request_result(res)
**Description**
           Edits an existing team. All arguments are optional. Team settings for any arguments unspecified will remain at their current settings.

        **Arguments**
            - **name**: the name of the team to edit.
            - **memberships**: dictionary of (user-name, team-role) pairs that should describe new memberships of the team.
            - **filter**: the scope that this team is able to access within Sysdig Monitor.
            - **description**: describes the team that will be created.
            - **show**: possible values are *host*, *container*.
            - **theme**: the color theme that Sysdig Monitor will use when displaying the team.
            - **perm_capture**: if True, this team will be allowed to take sysdig captures.
            - **perm_custom_events**: if True, this team will be allowed to view all custom events from every user and agent.
            - **perm_aws_data**: if True, this team will have access to all AWS metrics and tags, regardless of the team's scope.

        **Success Return Value**
            The edited team.

        **Example**
            `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_