Example #1
0
 def _post_organization_role(self,
                             organization_name,
                             role_name,
                             remove=False):
     organization = self._tower.get_organization_by_name(organization_name)
     if not organization:
         raise InvalidOrganization(organization_name)
     return self._post_permission(organization.object_roles, role_name,
                                  remove)
Example #2
0
    def organization(self, value):
        """Update the organization attached to the project.

        Returns:
            None:

        """
        organization = self._tower.get_organization_by_name(value)
        if not organization:
            raise InvalidOrganization(value)
        self._update_values('organization', organization.id)
Example #3
0
    def organization(self, value):
        """Set the organization of the credential.

        Returns:
            None.

        """
        organization = self._tower.get_organization_by_name(value)
        if not organization:
            raise InvalidOrganization(value)
        self._update_values('organization', organization.id)
Example #4
0
    def organization(self, value):
        """Update the organization of the inventory.

        Returns:
            None:

        """
        organization = self._tower.get_organization_by_name(value)
        if not organization:
            raise InvalidOrganization(value)
        self._update_values('organization', organization.id)
Example #5
0
    def organization(self, value):
        """Set the organization of the credential

        Returns:
            bool: True if successful, False otherwise

        """
        payload = {
            attribute: self._data.get(attribute)
            for attribute in self._payload
        }
        organization = self._tower.get_organization_by_name(value)
        if not organization:
            raise InvalidOrganization(value)
        payload['organization'] = organization.id
        return self._update_values(payload)
Example #6
0
    def disassociate_from_organization_role(self, organization, role):
        """Disassociate a user to an organizational role.

        Args:
            organization: The organization object that we want to assign to
            role: The role we want to assign to the object

        Returns:
            bool: If it managed to disassociate the user to the organization

        """
        organization_ = self._tower.get_organization_by_name(organization)
        if not organization_:
            raise InvalidOrganization(organization)
        role_id = organization_._get_object_role_id(role)  # pylint: disable=protected-access
        if role_id is None:
            raise InvalidRole(role)
        return self._assign_permission_role(role_id, disassociate=True)