devopshq / tfs

Microsoft TFS API Python client
https://devopshq.github.io/tfs/
MIT License
110 stars 28 forks source link

Leverage Encapsulated Functional #13

Closed jjj4x closed 6 years ago

jjj4x commented 6 years ago

There's an encapsulated functional that doesn't seem to be in the Public API.

More specifically:

  1. Workitems have protected attribute _data: workitem._data which is a dict()
  2. Inside the dict() there's an interesting key relations (workitem._data["relations"])
  3. The relations is a list() which contains multiple dict() objects
  4. The practical value lies in dict() objects that represent an attached file

Concrete example: ... logging.info(workitem._data["relations"][-1]) ...

STDOUT: {'rel': 'AttachedFile', 'url': '<uniquely identified link to the file>', 'attributes': {'authorizedDate': '2017-01-09T14:49:32.633Z', 'id': ..., 'resourceCreatedDate': '2017-01-09T14:49:10.473Z', 'resourceModifiedDate': '2017-01-09T14:49:10.473Z', 'revisedDate': '9999-01-01T00:00:00Z', 'resourceSize': 100937, 'name': '<filename>.png'}}

I'm still not sure, but it seems that the ability to work with attached files is already encapsulated.

Another interesting key is workitem._data["_links"], which contains: {'self': {'href': '<link to the workitem in JSON>'}, 'workItemUpdates': {'href': '...'}, 'workItemRevisions': {'href': '...'}, 'workItemHistory': {'href': '<link to workitem's comments in JSON>'}, 'html': {'...'}, 'workItemType': {'...'}, 'fields': {'href': '...'}}

allburov commented 6 years ago

Will be fix in #16

allburov commented 6 years ago

Fixed in dohq-tfs==1.0.54 Also read more https://github.com/devopshq/tfs/blob/master/docs/ADVANCED.md https://github.com/devopshq/tfs#workitem-attachments