Skip to content

Commit e16c110

Browse files
Merge pull request #197 from Asana/rossgrambo-openapi-conversion
Conversion to openapi spec
2 parents 5cb6610 + 51d4633 commit e16c110

Some content is hidden

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

51 files changed

+4610
-2083
lines changed

.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/api/*

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ npm test
273273

274274
### Code generation
275275

276-
The specific Asana resource classes (`Tag`, `Workspace`, `Task`, etc.) are
276+
The specific Asana resource classes within the gen folder (`Tag`, `Workspace`, `Task`, etc.) are
277277
generated code, hence they shouldn't be modified by hand.
278278

279-
See the [asana-api-meta][meta] repo for details.
279+
See our [openapi spec][https://github.com/Asana/developer-docs/blob/master/defs/asana_oas.yaml] and [swagger](https://github.com/swagger-api/swagger-codegen) for details.
280280

281281
### Deployment
282282

@@ -302,8 +302,4 @@ Travis CI will automatically build and deploy the tagged release.
302302
[co]: https://github.com/visionmedia/co
303303
[highland]: http://highlandjs.org/
304304

305-
[meta]: https://github.com/Asana/asana-api-meta
306-
[api-docs]: https://asana.com/developers
307-
[api-reference]: https://asana.com/developers/api-reference
308-
[io]: https://asana.com/developers/documentation/getting-started/input-output-options
309-
[asana-doc]: https://asana.com/developers/documentation
305+
[asana-docs]: https://developers.asana.com/docs

lib/resources/attachments.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
11
var Attachments = require('./gen/attachments');
2+
/* jshint ignore:start */
3+
var util = require('util');
24

5+
/**
6+
* Returns the full record for a single attachment.
7+
* @param {String} attachment Globally unique identifier for the attachment.
8+
* @param {Object} [params] Parameters for the request
9+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher
10+
* for the request
11+
* @return {Promise} The requested resource
12+
*/
13+
Attachments.prototype.findById = function(
14+
attachment,
15+
params,
16+
dispatchOptions
17+
) {
18+
var path = util.format('/attachments/%s', attachment);
19+
20+
return this.dispatchGet(path, params, dispatchOptions);
21+
};
22+
23+
/**
24+
* Returns the compact records for all attachments on the task.
25+
* @param {String} task Globally unique identifier for the task.
26+
* @param {Object} [params] Parameters for the request
27+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher
28+
* for the request
29+
* @return {Promise} The response from the API
30+
*/
31+
Attachments.prototype.findByTask = function(
32+
task,
33+
params,
34+
dispatchOptions
35+
) {
36+
var path = util.format('/tasks/%s/attachments', task);
37+
38+
return this.dispatchGetCollection(path, params, dispatchOptions);
39+
};
40+
41+
42+
/* jshint ignore:end */
343
module.exports = Attachments;

lib/resources/batch_api.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var BatchAPI = require('./gen/batch_api');
2+
3+
module.exports = BatchAPI;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
11
var CustomFieldSettings = require('./gen/custom_field_settings');
2+
/* jshint ignore:start */
3+
var util = require('util');
24

5+
/**
6+
* Returns a list of all of the custom fields settings on a project.
7+
* @param {String} project The ID of the project for which to list custom field settings
8+
* @param {Object} [params] Parameters for the request
9+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
10+
* @return {Promise} The response from the API
11+
*/
12+
CustomFieldSettings.prototype.findByProject = function(
13+
project,
14+
params,
15+
dispatchOptions
16+
) {
17+
var path = util.format('/projects/%s/custom_field_settings', project);
18+
19+
return this.dispatchGetCollection(path, params, dispatchOptions);
20+
};
21+
22+
/**
23+
* Returns a list of all of the custom fields settings on a portfolio.
24+
* @param {String} portfolio The ID of the portfolio for which to list custom field settings
25+
* @param {Object} [params] Parameters for the request
26+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
27+
* @return {Promise} The response from the API
28+
*/
29+
CustomFieldSettings.prototype.findByPortfolio = function(
30+
portfolio,
31+
params,
32+
dispatchOptions
33+
) {
34+
var path = util.format('/portfolios/%s/custom_field_settings', portfolio);
35+
36+
return this.dispatchGetCollection(path, params, dispatchOptions);
37+
};
38+
39+
40+
/* jshint ignore:end */
341
module.exports = CustomFieldSettings;

lib/resources/custom_fields.js

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,183 @@
11
var CustomFields = require('./gen/custom_fields');
2+
/* jshint ignore:start */
3+
var util = require('util');
4+
5+
/**
6+
* 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.
7+
*
8+
* 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'.
9+
*
10+
* Returns the full record of the newly created custom field.
11+
* @param {Object} data Data for the request
12+
* @param {String} data.workspace The workspace to create a custom field in.
13+
* @param {String} data.resource_subtype The type of the custom field. Must be one of the given values.
14+
* @param {String} [data.type] **Deprecated: New integrations should prefer the `resource_subtype` parameter.**
15+
* @param {String} data.name The name of the custom field.
16+
* @param {String} [data.description] The description of the custom field.
17+
* @param {Integer} [data.precision] The number of decimal places for the numerical values. Required if the custom field is of type 'number'.
18+
* @param {String} [data.enum_options] The discrete values the custom field can assume. Required if the custom field is of type 'enum'.
19+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
20+
* @return {Promise} The response from the API
21+
*/
22+
CustomFields.prototype.create = function(
23+
data,
24+
dispatchOptions
25+
) {
26+
var path = util.format('/custom_fields');
27+
28+
return this.dispatchPost(path, data, dispatchOptions);
29+
};
30+
31+
/**
32+
* Returns the complete definition of a custom field's metadata.
33+
* @param {String} custom_field Globally unique identifier for the custom field.
34+
* @param {Object} [params] Parameters for the request
35+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
36+
* @return {Promise} The requested resource
37+
*/
38+
CustomFields.prototype.findById = function(
39+
customField,
40+
params,
41+
dispatchOptions
42+
) {
43+
var path = util.format('/custom_fields/%s', customField);
44+
45+
return this.dispatchGet(path, params, dispatchOptions);
46+
};
47+
48+
/**
49+
* Returns a list of the compact representation of all of the custom fields in a workspace.
50+
* @param {String} workspace The workspace or organization to find custom field definitions in.
51+
* @param {Object} [params] Parameters for the request
52+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
53+
* @return {Promise} The response from the API
54+
*/
55+
CustomFields.prototype.findByWorkspace = function(
56+
workspace,
57+
params,
58+
dispatchOptions
59+
) {
60+
var path = util.format('/workspaces/%s/custom_fields', workspace);
61+
62+
return this.dispatchGetCollection(path, params, dispatchOptions);
63+
};
64+
65+
/**
66+
* 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
67+
*
68+
* 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.
69+
*
70+
* 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`.
71+
*
72+
* Locked custom fields can only be updated by the user who locked the field.
73+
*
74+
* Returns the complete updated custom field record.
75+
* @param {String} custom_field Globally unique identifier for the custom field.
76+
* @param {Object} data Data for the request
77+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
78+
* @return {Promise} The response from the API
79+
*/
80+
CustomFields.prototype.update = function(
81+
customField,
82+
data,
83+
dispatchOptions
84+
) {
85+
var path = util.format('/custom_fields/%s', customField);
86+
87+
return this.dispatchPut(path, data, dispatchOptions);
88+
};
89+
90+
/**
91+
* A specific, existing custom field can be deleted by making a DELETE request on the URL for that custom field.
92+
*
93+
* Locked custom fields can only be deleted by the user who locked the field.
94+
*
95+
* Returns an empty data record.
96+
* @param {String} custom_field Globally unique identifier for the custom field.
97+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
98+
* @return {Promise} The response from the API
99+
*/
100+
CustomFields.prototype.delete = function(
101+
customField,
102+
dispatchOptions
103+
) {
104+
var path = util.format('/custom_fields/%s', customField);
105+
106+
return this.dispatchDelete(path, dispatchOptions);
107+
};
108+
109+
/**
110+
* 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.
111+
*
112+
* Locked custom fields can only have enum options added by the user who locked the field.
113+
*
114+
* Returns the full record of the newly created enum option.
115+
* @param {String} custom_field Globally unique identifier for the custom field.
116+
* @param {Object} data Data for the request
117+
* @param {String} data.name The name of the enum option.
118+
* @param {String} [data.color] The color of the enum option. Defaults to 'none'.
119+
* @param {String} [data.insert_before] 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.
120+
* @param {String} [data.insert_after] 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.
121+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
122+
* @return {Promise} The response from the API
123+
*/
124+
CustomFields.prototype.createEnumOption = function(
125+
customField,
126+
data,
127+
dispatchOptions
128+
) {
129+
var path = util.format('/custom_fields/%s/enum_options', customField);
130+
131+
return this.dispatchPost(path, data, dispatchOptions);
132+
};
133+
134+
/**
135+
* Updates an existing enum option. Enum custom fields require at least one enabled enum option.
136+
*
137+
* Locked custom fields can only be updated by the user who locked the field.
138+
*
139+
* Returns the full record of the updated enum option.
140+
* @param {String} enum_option Globally unique identifier for the enum option.
141+
* @param {Object} data Data for the request
142+
* @param {String} data.name The name of the enum option.
143+
* @param {String} [data.color] The color of the enum option. Defaults to 'none'.
144+
* @param {Boolean} [data.enabled] Whether or not the enum option is a selectable value for the custom field.
145+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
146+
* @return {Promise} The response from the API
147+
*/
148+
CustomFields.prototype.updateEnumOption = function(
149+
enumOption,
150+
data,
151+
dispatchOptions
152+
) {
153+
var path = util.format('/enum_options/%s', enumOption);
154+
155+
return this.dispatchPut(path, data, dispatchOptions);
156+
};
157+
158+
/**
159+
* Moves a particular enum option to be either before or after another specified enum option in the custom field.
160+
*
161+
* Locked custom fields can only be reordered by the user who locked the field.
162+
* @param {String} custom_field Globally unique identifier for the custom field.
163+
* @param {Object} data Data for the request
164+
* @param {String} data.enum_option The ID of the enum option to relocate.
165+
* @param {String} data.name The name of the enum option.
166+
* @param {String} [data.color] The color of the enum option. Defaults to 'none'.
167+
* @param {String} [data.before_enum_option] 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.
168+
* @param {String} [data.after_enum_option] 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.
169+
* @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request
170+
* @return {Promise} The response from the API
171+
*/
172+
CustomFields.prototype.insertEnumOption = function(
173+
customField,
174+
data,
175+
dispatchOptions
176+
) {
177+
var path = util.format('/custom_fields/%s/enum_options/insert', customField);
178+
179+
return this.dispatchPost(path, data, dispatchOptions);
180+
};
2181

3182
/**
4183
* This is for compatibility reasons. Please use createEnumOption.
@@ -11,4 +190,6 @@ CustomFields.prototype.addEnumOption = CustomFields.prototype.createEnumOption;
11190
CustomFields.prototype.reorderEnumOption =
12191
CustomFields.prototype.insertEnumOption;
13192

193+
194+
/* jshint ignore:end */
14195
module.exports = CustomFields;

lib/resources/events.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var EventStream = require('../util/event_stream');
22
var Events = require('./gen/events');
3+
/* jshint ignore:start */
4+
var util = require('util');
35

46
/**
57
* Dispatches a GET request to /events of the API to get a set of recent
@@ -34,5 +36,6 @@ Events.prototype.stream = function(resourceId, options) {
3436
return new EventStream(this, resourceId, options);
3537
};
3638

39+
/* jshint ignore:end */
3740
Events.EventStream = EventStream;
3841
module.exports = Events;

0 commit comments

Comments
 (0)