Code Monkey home page Code Monkey logo

python-taiga's Introduction

python-taiga's People

Contributors

astagi avatar bameda avatar christophmeissner avatar dfederschmidt avatar dionysiusmarquis avatar erikw avatar gavanfantom avatar heieisch avatar jespino avatar jgarte avatar lekum avatar mfkaptan avatar mlq avatar morlandi avatar paoloromolini avatar pre-commit-ci[bot] avatar protoroto avatar psybers avatar rgson avatar skob avatar uc-cjdavis avatar yakky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-taiga's Issues

Search Fails if Wikipages Aren't Enabled

Description

api.search fails if wikipages are not enabled.

Steps to reproduce

Select a project.id for a project in which wikipages aren't enabled
Run api.search(project.id, 'search term')

Versions

Python Version: 3.9.1
python-taiga version: latest (1.0)

Expected behaviour

api.search should return a taiga.client.SearchResult object

Actual behaviour

api.search throws the following error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/taiga/client.py", line 100, in search
    search_result.wikipages = self.wikipages.parse_list(
KeyError: 'wikipages'

Additional information

If the following fix is acceptable, I'll submit a pull request.
This basically wraps a conditional around line 100 in client.py

        if project.is_wiki_activated:
            search_result.wikipages = self.wikipages.parse_list(
                result['wikipages']
            )
        else:
            search_result.epics = self.epics.parse_list(
                result['epics']
            )

Missing description for user stories?

Description

When creating a user story you have the option to specify a description, but when you get the UserStory that is created you can't access that variable. There is a "comment" field, I'm not sure if those are supposed to be the same

Steps to reproduce

  1. Create a user story following the steps here https://pypi.org/project/python-taiga/, make sure to add a description
  2. Access the newly created UserStory object and try to find the description you just added.

Versions

Python version 3.7.3

Expected behaviour

A 'description' variable that holds the description you just added. You can see it when you access Taiga in the browser, just not in code.

Actual behaviour

No description.

Additional information

The comment variable is empty too

Auto-refresh token after auth_token expired

Is it possible to auto-refresh auth_token? By that I mean, user first authenticate with login and password, store auth_token and refresh_token in db and after that use auth_token to authenticate and when auth_token expired, use (somehow) refresh_token for new token and again, store them in db?

Missing Info with list functions

Description

  • According to #52 when using list function it return the object with less information but when using get it returns all object information, What I ask about if there is an additional attribute in the listing function to return all information.
  • It seems not efficient to "Call the same object twice"

Use cases

list_issues, list_user_stories, list_projects, list_users, list_milestones and etc

Proposed solution

  • Add full_info attribute in the listing function
  • set the default to false if that will help to make it run faster
  • if anyone need the full info will pass it true, maybe take longer time but it will be faster than calling the same object twice
  • More efficient: memory, coding and performance wise.

Alternatives

Make new listing functions that retrieve only the ids as list of int

Incomplete results for queries about user story history

When querying a user story's history, the returned results are incomplete for stories with a long history.

The reason is pagination and the cutoff appears to be 30 entries. The function TaigaAPI.history.user_story.get does not support the pagination API, making it impossible (as far as I know) to get the remaining records.

I've applied the following patch to my local installation to bypass the issue:

  class HistoryEntity(object):
      """
      HistoryEntity model
      """
      endpoint = 'history'
  
      def __init__(self, requester):
          self.requester = requester
  
      def get(self, resource_id):
          """
          Get a history element
  
          :param resource_id: ...
          """
          response = self.requester.get(
              '/{endpoint}/{entity}/{id}',
-             endpoint=self.endpoint, entity=self.entity, id=resource_id
+             endpoint=self.endpoint, entity=self.entity, id=resource_id,
+             paginate=False
          )
          return response.json()

I'll gladly submit a pull request for it, but it is a bit ad hoc and could potentially cause the same problems that led to the pagination API being implemented in the first place, should there be user stories with a ridiculous amount of history.

Let me know what you think.

User Story "Description" Attribute Missing

I can't seem to get the "description" field from any of the UserStory objects that I've queried.
My script is like this:

stories = api.user_stories.list(project=project_id)
for story in stories:
    description = story.description

But I get an AttributeError:
AttributeError: 'UserStory' object has no attribute 'description'

It makes no sense to me, since all the other attributes of the story seem to be available through the api. When I do story.to_dict() it looks something like this:

{'sprint_order': 0, 'version': 5, 'kanban_order': 1490745956782, 'client_requirement': False, 'status': 86, 'milestone': 10, 'points': {'90': 163, '85': 163, '86': 163, '89': 163, '88': 163, '87': 163}, 'backlog_order': 1490745956784, 'assigned_to': 17, 'is_blocked': False, 'project': 16, 'subject': 'Review current provisional patent application', 'blocked_note': '', 'team_requirement': False, 'is_closed': False, 'watchers': [], 'tags': []}

Perhaps I've missed something simple.

Setting default statuses of a Taiga project

Hi,

First of all, nice job!

I am trying to create Taiga projects using this api. I wonder if there is a way to set default statuses (default_us_status, default_task_status, default_issue_status ..) for a project. Something like:

p = api.projects.create("name", "description")
p.default_us_status = p.us_statuses[0].id
..
p.update()

Right now when I create the project the default statuses are null.

cannot set watchers while creating issue

When creating issue like

issue = api.issues.create(project, feedback.user_login + " : " + feedback.brief_description,
                                  482, 1119, issue_type, 803,
                                  description=feedback.feedback, assigned_to=81, watchers=[81, 82])

watchers will not set to provided users id
Maybe I use your API not correctly, but if i set single id of user, there are still no difference

Add capability to retrieve user information.

To my understanding there is currently no way of retrieving user information through python-taiga.
A user story has an assigned_to field containing the user id of the assigned person. At the moment I'm manually retrieving the user information through the API but it would be nicer to have this functionality inside this package.

Projects using python-taiga

I would like to add a section listing the projects that use python-taiga

If you run one, please add the link here with a comment

Fix ruff linting error

Description

Latest ruff update enforces the use of isinstance to compare objects types

pagination, page always returns the first page

Description

when you have more than 300 User stories (2071 in the one I'm working with) setting page=y will return the same results no matter the value of y

Steps to reproduce

    the_page_size = 100

    for y in range(1,10):
        stories = api.user_stories.list(project=44, page=y, page_size=the_page_size)
        for x in stories:
            print(x.subject)
        print("*** Page *** ", y, "Len: ",len(stories))

Versions

Expected behaviour

when incrementing "page" and re calling I would expect the next page of results to be returned

Actual behaviour

whatever value is set the first page is returned

Additional information

Request was throttled.Expected available in 86097 seconds.

I was using this API to send out a massive amount of invites for a class to create public projects and adding members. It throttled at adding members. For some reason, my connection to Taiga Server is extremely slow. I have 100mbps at home and it takes 5 secs to load the website. I am not sure if it has anything to do with it. Thoughts? Thank you!

Stuck when trying to get a project object

when I try to do this

new_project = api.projects.get_by_slug(taiga.project_name)

I get

Starting new HTTPS connection (1): api.taiga.io
<taiga.client.TaigaAPI object at 0x7f4b3f9030f0>
SLUG????  Trigger-Happy endpoint  projects
Starting new HTTPS connection (1): api.taiga.io
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.4/multiprocessing/pool.py", line 420, in _handle_results
    task = get()
  File "/usr/lib/python3.4/multiprocessing/connection.py", line 251, in recv
    return ForkingPickler.loads(buf.getbuffer())
TypeError: __init__() missing 1 required positional argument: 'status_code'

I made a print inside of get_by_slug and could print the "slug" like we can see above, but once it tries

        response = self.requester.get(
            '/{endpoint}/by_slug?slug={slug}',
            endpoint=self.instance.endpoint,
            slug=slug
        )

its over, i'm stuck

No such file error for README.rst during setup

running python setup.py egg_info gives

Traceback (most recent call last):
  File "setup.py", line 33, in <module>
    long_description=read('README.rst'),
  File "setup.py", line 8, in read
    return open(os.path.join(os.path.dirname(__file__), fname)).read()
IOError: [Errno 2] No such file or directory: 'README.rst'

I think it should be README.md instead of README.rst

LDAP auth not provided

Hi,

As an LDAP user, I would like to have an ldap auth provided by python-taiga. I can't use python-taiga as long as ldap auth is not supported.

Thanks in advance.

Missing refresh name:value pair in auth_user_success.json resource

Description

The tests/resources/auth_user_success.json file used in the tests.test_auth is missing the refresh token name:value pair that is available after a successful auth to the Taiga REST API (ref: https://docs.taiga.io/api.html#object-auth-user-detail). If the client.auth() function definition is updated to capture the refresh token, the tests.test_auth fails

Steps to reproduce

  1. Add after line 144 in client.py
    self.token_refresh = response.json()['refresh']
  2. Run tox -e pyx.x

Versions

Python 3.9
python-taiga latest version

Expected behaviour

Tests.test_auth.py runs successfully after feature added to code

Actual behaviour

Test fails

Additional information

This bug is being filed prior to a PR submission for a fix that will support another PR submission for refresh token support. Capturing the auth returned refresh token will allow for using the refresh auth token endpoint of the Taiga REST API

AttributeError: 'History' object has no attribute 'id'

Hi,

I think one of the latest taiga-back commits broke python-taiga if not entirely but quite badly.
I see they made changes to the history management in taiga-back (they fixed something with timeline history loops on fresh projects) and I suppose it had some effect on this tool.

This gets raised when I'm trying to get a project by its slug:
AttributeError: 'History' object has no attribute 'id'

Got no idea where to fix it yet.

Creating a task with description or comment

Hi,

First, thanks for a great lib.

Second, I am trying to create a task in a userstory in which I add a description to the attrs dictionary:

attr = { 'description' : 'my description' }
userstory.add_task(subject = ticket_id, status = id, attrs = attr)

However when the task do not get the description when created? I suspect that I am doing something wrong here but I am not sure what.

Project templates

Hello,

I've been using this fine library for an internal project and I need to define project templates. I've done some work and I've added some basic models that create an empty template. I will add some more functionality to create roles, points etc in the template definition.

I'd like to merge this here if you are interested in templates. What do you think?

How to get project slug?

Description

Hi, I want to get project slug. I need project slug to create full front-end link (eg. https://mytaigahost.com/project/<project_slug>/us/<userstory_id>) of user stories and tasks.
Sorry, but I don't understand how to get it. Can you help me?

Steps to reproduce

projects = api.projects.list()
not return project slug.

Versions

python-taiga 1.0.0
taiga 6.0.0

Documentation

I'd like to use sphinx for documentation. First of all we need some descriptive pages with general examples to show how python-taiga works, e.g. "Authentication", "Create your first project", "Dealing with user stories", "Attach a file to your tasks and issues". The best resources to accomplish this first step are the README.md and demo.py file in the root of the project, they show how python-taiga library works.

Python-taiga contains a lot of models and a client module, classes should be documented following this pattern: https://github.com/twilio/twilio-python/blob/master/twilio/rest/resources/addresses.py#L39

Required Param 'moveTo' error message while deleting a user story status

Description

I'd like to delete User Story Status(es) by using the Python API.
If I try to delete a Status via API, the console output (error message) says:
taiga.exceptions.TaigaRestException: Query param 'moveTo' is required
When inspecting the web request this correlating element is visible, but I didn't find any way to do this via API.

Maybe I'm only using the API in an incorrect way.
But as you can see, in base.py the delete function only contains (self, resource_id). Executing the function with more than only the ID to be deleted (say: the "moveTo" ID), the error message says that there are too many params.

Steps to reproduce

  • By creating a fresh Project, predefined UserStoryStatus(es) are created too
  • Get a complete list by api.user_story_statuses.list
  • Try to delete it via api.user_story_statuses.delete(123)

Versions

  • Python 3.10.6
  • Taiga 6.6.0
  • python-taiga 1.1

thanks, br

api_error_1
function definition
web request

requrests 2.11 requires string only headers

api.projects.get_by_slug() can't work because requests 2.11 changed to accept string only headers.

https://github.com/kennethreitz/requests/issues/3477

Error

Traceback (most recent call last):
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/requests/utils.py", line 796, in check_header_validity
    if not pat.match(value):
TypeError: expected string or buffer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/taiga/requestmaker.py", line 102, in get
    params=query
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/requests/sessions.py", line 461, in request
    prep = self.prepare_request(req)
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/requests/sessions.py", line 394, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/requests/models.py", line 295, in prepare
    self.prepare_headers(headers)
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/requests/models.py", line 409, in prepare_headers
    check_header_validity(header)
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/requests/utils.py", line 800, in check_header_validity
    "not %s" % (value, type(value)))
requests.exceptions.InvalidHeader: Header value True must be of type str or bytes, not <class 'bool'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "src/taiga_io.py", line 28, in <module>
    pprint(api.me())
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/taiga/client.py", line 88, in me
    return self.users.get('me')
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/taiga/models/base.py", line 47, in get
    endpoint=self.instance.endpoint, id=resource_id
  File "/Users/tetor/.pyenv/versions/cf-tpp/lib/python3.4/site-packages/taiga/requestmaker.py", line 109, in get
    'Network error!', 'GET'
taiga.exceptions.TaigaRestException: Network error!

set custom attribute throws exception

setting existing custom attribute throws exception:

us.set_attribute('35', 'Desktop')

taiga.exceptions.TaigaRestException: Attribute with id 35 doesn't exist

Native Proxy support

For a script within customer network there is a need for proxy support.

What works is using environment http_proxy / https_proxy which is luckely supported from the requests module. But this is kind unflexible when accessing an external and internal taiga instance at the same time.

Where is a good starting point, adding proxy support to this module?

Support for wiki attachments

Description

It would be great to manage wikipage attachments in a similar fashion

Use cases

Migrating / syncing wiki pages

Proposed solution

Extending the wikipage class with a list_attachments method

Alternatives

Right now, it seems to me i have to parse the HTML of a wikipage and find the URL's of the attachments to get them using requests .

Cannot get Ref ID of user stories

The attributes that each story in stories does not include the ref number of the task.
stories = taigaBoard.list_user_stories()

I'm a REST API newbie so if I am missing something obvious sorry.

Project listing agains taiga.io fails: too many projects

Hello,

I noticed that if you use python-taiga against https://api.taiga.io/ to list projects it fails.

api.projects.list()
(Traceback (most recent call last):
  File "./taiga-stats", line 175, in cmd_list_projects
    for proj in api.projects.list():
  File "/home/erikw/.virtualenvs/taiga-stats/lib/python3.6/site-packages/taiga/models/base.py", line 41, in list
    objects = self.parse_list(result.json())
  File "/home/erikw/.virtualenvs/taiga-stats/lib/python3.6/site-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

No output fed in to the JSON decoding? So I decided to get down to my friend command line, and this works as expected:

$ curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ${AUTH_TOKEN}" -s https://api.taiga.io/api/v1/projects
...
<project JSON>

So I drilled down the code and noticed that python-taiga always send the header

x-disable-pagination: True

to disable pagination and get everything at once.

So I plugged this in to the the previous command line

$ curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ${AUTH_TOKEN}" -H "x-disable-pagination: True" -s https://api.taiga.io/api/v1/projects
<html>
<head><title>504 Gateway Time-out</title></head>
<body bgcolor="white">
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx/1.10.3 (Ubuntu)</center>
</body>
</html>

and now it it also fails like when called with pyhon-taiga.

I simply think this is the situation: now the number of public projects at taiga.io has recently grown too large to be included in one GET request to the project listing API endpoint. But before it was small enough to work.

A user of my project taiga-stats reported this last week.

I guess python-taiga should be adapted to use pagination for requests, so it can handle large taiga instances, like taiga.io now is. And I think this is prioritized to to, as I guess taiga.io is the most used instance of Taiga of them all!

list_epic_attributes() function is missing

Description

A list_user_story_attributes() function exists, but no corresponding function exists for epics.

Use cases

To get a list of attributes on an epic.

Proposed solution

A function list_epic_attributes() which returns a list of epic attributes, mirroring the functionality for list_user_stories()

Alternatives

None

Additional information

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.