Create a Scope.

        This will create a scope if the client has the right to do so. Sufficient permissions to create a scope are a
        superuser, a user in the `GG:Configurators` group or `GG:Managers` group.

        ..versionadded: 2.6

        :param name: Name of the scope
        :type name: basestring
        :param status: choose one of the :class:`enums.ScopeStatus`, defaults to `ScopeStatus.ACTIVE`
        :type status: basestring or None
        :param description: (optional) Description of the scope
        :type description: basestring or None
        :param tags: (optional) List of tags to be added to the new scope
        :type tags: list or None
        :param start_date: (optional) start date of the scope. Will default to 'now' if not provided.
        :type start_date: datetime.datetime or None
        :param due_date: (optional) due date of the scope
        :type due_date: datetime.datetime or None
        :param team: (optional) team_id or Team object to assign membership of scope to a team.
        :type team: basestring or :class:`models.Team` or None
        :param kwargs: optional additional search arguments
        :type kwargs: dict or None
        :return: the created :class:`models.Scope`
        :raises APIError: In case of failure of the creation of new Scope

def create_scope(self, name, status=ScopeStatus.ACTIVE, description=None, tags=None, start_date=None, due_date=None,
                     team=None, **kwargs):
        """
        Create a Scope.

        This will create a scope if the client has the right to do so. Sufficient permissions to create a scope are a
        superuser, a user in the `GG:Configurators` group or `GG:Managers` group.

        ..versionadded: 2.6

        :param name: Name of the scope
        :type name: basestring
        :param status: choose one of the :class:`enums.ScopeStatus`, defaults to `ScopeStatus.ACTIVE`
        :type status: basestring or None
        :param description: (optional) Description of the scope
        :type description: basestring or None
        :param tags: (optional) List of tags to be added to the new scope
        :type tags: list or None
        :param start_date: (optional) start date of the scope. Will default to 'now' if not provided.
        :type start_date: datetime.datetime or None
        :param due_date: (optional) due date of the scope
        :type due_date: datetime.datetime or None
        :param team: (optional) team_id or Team object to assign membership of scope to a team.
        :type team: basestring or :class:`models.Team` or None
        :param kwargs: optional additional search arguments
        :type kwargs: dict or None
        :return: the created :class:`models.Scope`
        :raises APIError: In case of failure of the creation of new Scope
        """
        if not isinstance(name, (str, text_type)):
            raise IllegalArgumentError("'Name' should be provided as a string, was provided as '{}'".
                                       format(type(name)))
        if status not in ScopeStatus.values():
            raise IllegalArgumentError("Please provide a valid scope status, please use one of `enums.ScopeStatus`. "
                                       "Got: '{}'".format(status))
        if description and not isinstance(description, (str, text_type)):
            raise IllegalArgumentError("'Description' should be provided as a string, was provided as '{}'".
                                       format(type(description)))
        if tags and not isinstance(tags, list):
            raise IllegalArgumentError("'Tags' should be provided as a list, was provided as '{}'".
                                       format(type(tags)))
        if tags and not (all([isinstance(t, (str, text_type)) for t in tags])):
            raise IllegalArgumentError("Each tag in the list of tags should be provided as a string")

        if not start_date:
            start_date = datetime.datetime.now()
        if not tags:
            tags = list()

        data_dict = {
            'name': name,
            'status': status,
            'text': description,
            'tags': tags,
        }

        if start_date is not None:
            if isinstance(start_date, datetime.datetime):
                if not start_date.tzinfo:
                    warnings.warn("The duedate '{}' is naive and not timezone aware, use pytz.timezone info. "
                                  "This date is interpreted as UTC time.".format(start_date.isoformat(sep=' ')))
                data_dict['start_date'] = start_date.isoformat(sep='T')
            else:
                raise IllegalArgumentError('Start date should be a datetime.datetime() object')
        else:
            # defaults to now
            data_dict['start_date'] = datetime.datetime.now()

        if due_date is not None:
            if isinstance(due_date, datetime.datetime):
                if not due_date.tzinfo:
                    warnings.warn("The duedate '{}' is naive and not timezone aware, use pytz.timezone info. "
                                  "This date is interpreted as UTC time.".format(due_date.isoformat(sep=' ')))
                data_dict['due_date'] = due_date.isoformat(sep='T')
            else:
                raise IllegalArgumentError('Due date should be a datetime.datetime() object')

        if team is not None:
            if isinstance(team, Team):
                team_id = team.id
            elif is_uuid(team):
                team_id = team
            elif isinstance(team, (text_type, string_types)):
                team_id = self.team(name=team).id
            else:
                raise IllegalArgumentError("'Team' should be provided as a `models.Team` object or UUID or team name, "
                                           "was provided as a {}".format(type(team)))
            data_dict['team'] = team_id

        # injecting additional kwargs for those cases that you need to add extra options.
        data_dict.update(kwargs)

        response = self._request('POST', self._build_url('scopes'), data=data_dict)

        if response.status_code != requests.codes.created:  # pragma: no cover
            raise APIError("Could not create scope, {}:\n\n{}'".format(str(response), response.json()))

        return Scope(response.json()['results'][0], client=self)