Skip to content

Commit ebfbafb

Browse files
Merge pull request #103 from Asana/rossgrambo-openapi-convert
Conversion to openapi spec
2 parents d9e9cd9 + edceca8 commit ebfbafb

55 files changed

Lines changed: 3677 additions & 1808 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.swagger-codegen-ignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Swagger Codegen Ignore
2+
3+
docs/*
4+
test/*

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ lint and tests.
180180
### Code generation
181181

182182
The specific Asana resource classes under `gen` (`_Tag`, `_Workspace`, `_Task`, etc) are
183-
generated code, hence they shouldn't be modified by hand. See the [asana-api-meta][meta] repo for details.
183+
generated code, hence they shouldn't be modified by hand.
184184

185185
### Deployment
186186

@@ -208,3 +208,5 @@ Travis CI will automatically build and deploy the tagged release to `pypi`.
208208

209209
[pypi-url]: https://pypi.python.org/pypi/asana/
210210
[pypi-image]: https://img.shields.io/pypi/v/asana.svg?style=flat-square
211+
212+
[asana-docs]: https://developers.asana.com/docs

asana/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__title__ = 'asana'
2-
__version__ = '0.9.2'
2+
__version__ = '0.10.0'
33
__license__ = 'MIT'
44
__copyright__ = 'Copyright 2016 Asana, Inc.'
55

asana/resources/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from . import (
22
attachments,
3+
batch_api,
34
custom_field_settings,
45
custom_fields,
56
events,
@@ -15,8 +16,10 @@
1516
tags,
1617
tasks,
1718
teams,
19+
typeahead,
1820
users,
1921
user_task_lists,
2022
webhooks,
23+
workspace_memberships,
2124
workspaces
2225
)

asana/resources/attachments.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,25 @@ def create_on_task(self, task_id, file_content, file_name, file_content_type=Non
88
"""Upload an attachment for a task. Accepts a file object or string, file name, and optional file Content-Type"""
99
path = '/tasks/%s/attachments' % (task_id)
1010
return self.client.request('post', path, files=[('file', (file_name, file_content, file_content_type))], **options)
11+
12+
def find_by_id(self, attachment, params={}, **options):
13+
"""Returns the full record for a single attachment.
14+
15+
Parameters
16+
----------
17+
attachment : {Gid} Globally unique identifier for the attachment.
18+
[params] : {Object} Parameters for the request
19+
"""
20+
path = "/attachments/%s" % (attachment)
21+
return self.client.get(path, params, **options)
22+
23+
def find_by_task(self, task, params={}, **options):
24+
"""Returns the compact records for all attachments on the task.
25+
26+
Parameters
27+
----------
28+
task : {Gid} Globally unique identifier for the task.
29+
[params] : {Object} Parameters for the request
30+
"""
31+
path = "/tasks/%s/attachments" % (task)
32+
return self.client.get_collection(path, params, **options)

asana/resources/batch_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
from .gen.batch_api import _BatchAPI
3+
4+
class BatchAPI(_BatchAPI):
5+
"""BatchAPI resource"""
6+
pass

asana/resources/custom_field_settings.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,24 @@
33

44
class CustomFieldSettings(_CustomFieldSettings):
55
"""Custom Field Settings resource"""
6-
pass
6+
def find_by_project(self, project, params={}, **options):
7+
"""Returns a list of all of the custom fields settings on a project.
8+
9+
Parameters
10+
----------
11+
project : {Gid} The ID of the project for which to list custom field settings
12+
[params] : {Object} Parameters for the request
13+
"""
14+
path = "/projects/%s/custom_field_settings" % (project)
15+
return self.client.get_collection(path, params, **options)
16+
17+
def find_by_portfolio(self, portfolio, params={}, **options):
18+
"""Returns a list of all of the custom fields settings on a portfolio.
19+
20+
Parameters
21+
----------
22+
portfolio : {Gid} The ID of the portfolio for which to list custom field settings
23+
[params] : {Object} Parameters for the request
24+
"""
25+
path = "/portfolios/%s/custom_field_settings" % (portfolio)
26+
return self.client.get_collection(path, params, **options)

asana/resources/custom_fields.py

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,133 @@ def add_enum_option(self, custom_field, params={}, **options):
88

99
def reorder_enum_option(self, custom_field, params={}, **options):
1010
self.insert_enum_option(custom_field, params, **options)
11+
12+
def create(self, params={}, **options):
13+
"""Creates a new custom field in a workspace. Every custom field is required to be created in a specific workspace, and this workspace cannot be changed once set.
14+
15+
A custom field's `name` must be unique within a workspace and not conflict with names of existing task properties such as 'Due Date' or 'Assignee'. A custom field's `type` must be one of 'text', 'enum', or 'number'.
16+
17+
Returns the full record of the newly created custom field.
18+
19+
Parameters
20+
----------
21+
[data] : {Object} Data for the request
22+
- workspace : {Gid} The workspace to create a custom field in.
23+
- resource_subtype : {String} The type of the custom field. Must be one of the given values.
24+
- [type] : {String} **Deprecated: New integrations should prefer the `resource_subtype` parameter.**
25+
- name : {String} The name of the custom field.
26+
- [description] : {String} The description of the custom field.
27+
- [precision] : {Integer} The number of decimal places for the numerical values. Required if the custom field is of type 'number'.
28+
- [enum_options] : {String} The discrete values the custom field can assume. Required if the custom field is of type 'enum'.
29+
"""
30+
return self.client.post("/custom_fields", params, **options)
31+
32+
def find_by_id(self, custom_field, params={}, **options):
33+
"""Returns the complete definition of a custom field's metadata.
34+
35+
Parameters
36+
----------
37+
custom_field : {Gid} Globally unique identifier for the custom field.
38+
[params] : {Object} Parameters for the request
39+
"""
40+
path = "/custom_fields/%s" % (custom_field)
41+
return self.client.get(path, params, **options)
42+
43+
def find_by_workspace(self, workspace, params={}, **options):
44+
"""Returns a list of the compact representation of all of the custom fields in a workspace.
45+
46+
Parameters
47+
----------
48+
workspace : {Gid} The workspace or organization to find custom field definitions in.
49+
[params] : {Object} Parameters for the request
50+
"""
51+
path = "/workspaces/%s/custom_fields" % (workspace)
52+
return self.client.get_collection(path, params, **options)
53+
54+
def update(self, custom_field, params={}, **options):
55+
"""A specific, existing custom field can be updated by making a PUT request on the URL for that custom field. Only the fields provided in the `data` block will be updated; any unspecified fields will remain unchanged
56+
57+
When using this method, it is best to specify only those fields you wish to change, or else you may overwrite changes made by another user since you last retrieved the custom field.
58+
59+
An enum custom field's `enum_options` cannot be updated with this endpoint. Instead see "Work With Enum Options" for information on how to update `enum_options`.
60+
61+
Locked custom fields can only be updated by the user who locked the field.
62+
63+
Returns the complete updated custom field record.
64+
65+
Parameters
66+
----------
67+
custom_field : {Gid} Globally unique identifier for the custom field.
68+
[data] : {Object} Data for the request
69+
"""
70+
path = "/custom_fields/%s" % (custom_field)
71+
return self.client.put(path, params, **options)
72+
73+
def delete(self, custom_field, params={}, **options):
74+
"""A specific, existing custom field can be deleted by making a DELETE request on the URL for that custom field.
75+
76+
Locked custom fields can only be deleted by the user who locked the field.
77+
78+
Returns an empty data record.
79+
80+
Parameters
81+
----------
82+
custom_field : {Gid} Globally unique identifier for the custom field.
83+
"""
84+
path = "/custom_fields/%s" % (custom_field)
85+
return self.client.delete(path, params, **options)
86+
87+
def create_enum_option(self, custom_field, params={}, **options):
88+
"""Creates an enum option and adds it to this custom field's list of enum options. A custom field can have at most 50 enum options (including disabled options). By default new enum options are inserted at the end of a custom field's list.
89+
90+
Locked custom fields can only have enum options added by the user who locked the field.
91+
92+
Returns the full record of the newly created enum option.
93+
94+
Parameters
95+
----------
96+
custom_field : {Gid} Globally unique identifier for the custom field.
97+
[data] : {Object} Data for the request
98+
- name : {String} The name of the enum option.
99+
- [color] : {String} The color of the enum option. Defaults to 'none'.
100+
- [insert_before] : {Gid} An existing enum option within this custom field before which the new enum option should be inserted. Cannot be provided together with after_enum_option.
101+
- [insert_after] : {Gid} An existing enum option within this custom field after which the new enum option should be inserted. Cannot be provided together with before_enum_option.
102+
"""
103+
path = "/custom_fields/%s/enum_options" % (custom_field)
104+
return self.client.post(path, params, **options)
105+
106+
def update_enum_option(self, enum_option, params={}, **options):
107+
"""Updates an existing enum option. Enum custom fields require at least one enabled enum option.
108+
109+
Locked custom fields can only be updated by the user who locked the field.
110+
111+
Returns the full record of the updated enum option.
112+
113+
Parameters
114+
----------
115+
enum_option : {Gid} Globally unique identifier for the enum option.
116+
[data] : {Object} Data for the request
117+
- name : {String} The name of the enum option.
118+
- [color] : {String} The color of the enum option. Defaults to 'none'.
119+
- [enabled] : {Boolean} Whether or not the enum option is a selectable value for the custom field.
120+
"""
121+
path = "/enum_options/%s" % (enum_option)
122+
return self.client.put(path, params, **options)
123+
124+
def insert_enum_option(self, custom_field, params={}, **options):
125+
"""Moves a particular enum option to be either before or after another specified enum option in the custom field.
126+
127+
Locked custom fields can only be reordered by the user who locked the field.
128+
129+
Parameters
130+
----------
131+
custom_field : {Gid} Globally unique identifier for the custom field.
132+
[data] : {Object} Data for the request
133+
- enum_option : {Gid} The ID of the enum option to relocate.
134+
- name : {String} The name of the enum option.
135+
- [color] : {String} The color of the enum option. Defaults to 'none'.
136+
- [before_enum_option] : {Gid} An existing enum option within this custom field before which the new enum option should be inserted. Cannot be provided together with after_enum_option.
137+
- [after_enum_option] : {Gid} An existing enum option within this custom field after which the new enum option should be inserted. Cannot be provided together with before_enum_option.
138+
"""
139+
path = "/custom_fields/%s/enum_options/insert" % (custom_field)
140+
return self.client.post(path, params, **options)

asana/resources/gen/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from . import (
2+
attachments,
3+
batch_api,
4+
custom_field_settings,
5+
custom_fields,
6+
events,
7+
jobs,
8+
organization_exports,
9+
portfolios,
10+
portfolio_memberships,
11+
project_memberships,
12+
project_statuses,
13+
projects,
14+
sections,
15+
stories,
16+
tags,
17+
tasks,
18+
teams,
19+
typeahead,
20+
users,
21+
user_task_lists,
22+
webhooks,
23+
workspace_memberships,
24+
workspaces
25+
)

asana/resources/gen/attachments.py

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,49 @@
1-
1+
# coding=utf-8
22
class _Attachments:
3-
"""An _attachment_ object represents any file attached to a task in Asana,
4-
whether it's an uploaded file or one associated via a third-party service
5-
such as Dropbox or Google Drive.
6-
"""
73

84
def __init__(self, client=None):
95
self.client = client
10-
11-
def find_by_id(self, attachment, params={}, **options):
12-
"""Returns the full record for a single attachment.
136

14-
Parameters
15-
----------
16-
attachment : {Gid} Globally unique identifier for the attachment.
17-
[params] : {Object} Parameters for the request
7+
def delete_attachment(self, attachment_gid, params=None, **options):
8+
"""Delete an attachment
9+
:param str attachment_gid: (required) Globally unique identifier for the attachment.
10+
:param Object params: Parameters for the request
11+
:param **options
12+
- opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options.
13+
- opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging.
14+
:return: Object
15+
"""
16+
if params is None:
17+
params = {}
18+
path = "/attachments/{attachment_gid}".replace("{attachment_gid}", attachment_gid)
19+
return self.client.delete(path, params, **options)
20+
21+
def get_attachment(self, attachment_gid, params=None, **options):
22+
"""Get an attachment
23+
:param str attachment_gid: (required) Globally unique identifier for the attachment.
24+
:param Object params: Parameters for the request
25+
:param **options
26+
- opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options.
27+
- opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging.
28+
:return: Object
1829
"""
19-
path = "/attachments/%s" % (attachment)
30+
if params is None:
31+
params = {}
32+
path = "/attachments/{attachment_gid}".replace("{attachment_gid}", attachment_gid)
2033
return self.client.get(path, params, **options)
21-
22-
def find_by_task(self, task, params={}, **options):
23-
"""Returns the compact records for all attachments on the task.
2434

25-
Parameters
26-
----------
27-
task : {Gid} Globally unique identifier for the task.
28-
[params] : {Object} Parameters for the request
35+
def get_attachments_for_task(self, task_gid, params=None, **options):
36+
"""Get attachments for a task
37+
:param str task_gid: (required) The task to operate on.
38+
:param Object params: Parameters for the request
39+
:param **options
40+
- offset {str}: Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.'
41+
- limit {int}: Results per page. The number of objects to return per page. The value must be between 1 and 100.
42+
- opt_fields {list[str]}: Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options.
43+
- opt_pretty {bool}: Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging.
44+
:return: Object
2945
"""
30-
path = "/tasks/%s/attachments" % (task)
46+
if params is None:
47+
params = {}
48+
path = "/tasks/{task_gid}/attachments".replace("{task_gid}", task_gid)
3149
return self.client.get_collection(path, params, **options)
32-

0 commit comments

Comments
 (0)