From c35d4af3876901bb7446d2e7504331710c21726f Mon Sep 17 00:00:00 2001 From: John Vu Date: Fri, 4 Mar 2022 14:31:40 -0800 Subject: [PATCH] Generated from OpenAPI --- VERSION | 2 +- lib/resources/gen/project_templates.js | 101 +++++++++++++++++++++++++ lib/resources/gen/projects.js | 18 +++++ lib/resources/gen/typeahead.js | 2 +- package.json | 2 +- samples/project_templates_sample.yaml | 45 +++++++++++ samples/projects_sample.yaml | 11 +++ 7 files changed, 178 insertions(+), 3 deletions(-) create mode 100644 lib/resources/gen/project_templates.js create mode 100644 samples/project_templates_sample.yaml diff --git a/VERSION b/VERSION index c308ffef..d8158095 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.18.12 \ No newline at end of file +0.18.13 \ No newline at end of file diff --git a/lib/resources/gen/project_templates.js b/lib/resources/gen/project_templates.js new file mode 100644 index 00000000..1862ab40 --- /dev/null +++ b/lib/resources/gen/project_templates.js @@ -0,0 +1,101 @@ +/** + * This file is auto-generated by our openapi spec. + * We try to keep the generated code pretty clean but there will be lint + * errors that are just not worth fixing (like unused requires). + * TODO: maybe we can just disable those specifically and keep this code + * pretty lint-free too! + */ +/* jshint ignore:start */ +var Resource = require('../resource'); +var util = require('util'); +var _ = require('lodash'); + +function ProjectTemplates(dispatcher) { + Resource.call(this, dispatcher); +} +util.inherits(ProjectTemplates, Resource); + + +/** + * Get a project template + * @param {String} projectTemplateGid: (required) Globally unique identifier for the project template. + * @param {Object} params: Parameters for the request + - optFields {[String]}: 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. + - optPretty {Boolean}: 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. + * @param {Object} [dispatchOptions]: Options, if any, to pass the dispatcher for the request + * @return {Promise} The requested resource + */ +ProjectTemplates.prototype.getProjectTemplate = function( + projectTemplateGid, + params, + dispatchOptions +) { + var path = "/project_templates/{project_template_gid}".replace("{project_template_gid}", projectTemplateGid); + + return this.dispatchGet(path, params, dispatchOptions) +}; + + +/** + * Get multiple project templates + * @param {Object} params: Parameters for the request + - workspace {String}: The workspace to filter results on. + - team {String}: The team to filter projects on. + - offset {String}: 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.' + - limit {Number}: Results per page. The number of objects to return per page. The value must be between 1 and 100. + - optFields {[String]}: 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. + - optPretty {Boolean}: 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. + * @param {Object} [dispatchOptions]: Options, if any, to pass the dispatcher for the request + * @return {Promise} The requested resource + */ +ProjectTemplates.prototype.getProjectTemplates = function( + params, + dispatchOptions +) { + var path = "/project_templates"; + + return this.dispatchGetCollection(path, params, dispatchOptions) +}; + + +/** + * Get a team's project templates + * @param {String} teamGid: (required) Globally unique identifier for the team. + * @param {Object} params: Parameters for the request + - offset {String}: 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.' + - limit {Number}: Results per page. The number of objects to return per page. The value must be between 1 and 100. + - optFields {[String]}: 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. + - optPretty {Boolean}: 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. + * @param {Object} [dispatchOptions]: Options, if any, to pass the dispatcher for the request + * @return {Promise} The requested resource + */ +ProjectTemplates.prototype.getProjectTemplatesForTeam = function( + teamGid, + params, + dispatchOptions +) { + var path = "/teams/{team_gid}/project_templates".replace("{team_gid}", teamGid); + + return this.dispatchGetCollection(path, params, dispatchOptions) +}; + + +/** + * Instantiate a project from a project template + * @param {String} projectTemplateGid: (required) Globally unique identifier for the project template. + * @param {Object} data: Data for the request + * @param {Object} [dispatchOptions]: Options, if any, to pass the dispatcher for the request + * @return {Promise} The requested resource + */ +ProjectTemplates.prototype.instantiateProject = function( + projectTemplateGid, + data, + dispatchOptions +) { + var path = "/project_templates/{project_template_gid}/instantiateProject".replace("{project_template_gid}", projectTemplateGid); + + return this.dispatchPost(path, data, dispatchOptions) +}; + +module.exports = ProjectTemplates; +/* jshint ignore:end */ diff --git a/lib/resources/gen/projects.js b/lib/resources/gen/projects.js index 6b7adb1d..59c53783 100644 --- a/lib/resources/gen/projects.js +++ b/lib/resources/gen/projects.js @@ -291,6 +291,24 @@ Projects.prototype.getTaskCountsForProject = function( }; +/** + * Create a project template from a project + * @param {String} projectGid: (required) Globally unique identifier for the project. + * @param {Object} data: Data for the request + * @param {Object} [dispatchOptions]: Options, if any, to pass the dispatcher for the request + * @return {Promise} The requested resource + */ +Projects.prototype.projectSaveAsTemplate = function( + projectGid, + data, + dispatchOptions +) { + var path = "/projects/{project_gid}/saveAsTemplate".replace("{project_gid}", projectGid); + + return this.dispatchPost(path, data, dispatchOptions) +}; + + /** * Remove a custom field from a project * @param {String} projectGid: (required) Globally unique identifier for the project. diff --git a/lib/resources/gen/typeahead.js b/lib/resources/gen/typeahead.js index 9b01d26f..1b1b6fd8 100644 --- a/lib/resources/gen/typeahead.js +++ b/lib/resources/gen/typeahead.js @@ -20,7 +20,7 @@ util.inherits(Typeahead, Resource); * Get objects via typeahead * @param {String} workspaceGid: (required) Globally unique identifier for the workspace or organization. * @param {Object} params: Parameters for the request - - resourceType {String}: (required) The type of values the typeahead should return. You can choose from one of the following: `custom_field`, `project`, `portfolio`, `tag`, `task`, and `user`. Note that unlike in the names of endpoints, the types listed here are in singular form (e.g. `task`). Using multiple types is not yet supported. + - resourceType {String}: (required) The type of values the typeahead should return. You can choose from one of the following: `custom_field`, `project`, `project_template`, `portfolio`, `tag`, `task`, and `user`. Note that unlike in the names of endpoints, the types listed here are in singular form (e.g. `task`). Using multiple types is not yet supported. - type {String}: *Deprecated: new integrations should prefer the resource_type field.* - query {String}: The string that will be used to search for relevant objects. If an empty string is passed in, the API will currently return an empty result set. - count {Number}: The number of results to return. The default is 20 if this parameter is omitted, with a minimum of 1 and a maximum of 100. If there are fewer results found than requested, all will be returned. diff --git a/package.json b/package.json index ef7eed12..a19d21f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "asana", - "version": "0.18.12", + "version": "0.18.13", "description": "Official NodeJS and BrowserJS client for the Asana API", "main": "index.js", "scripts": { diff --git a/samples/project_templates_sample.yaml b/samples/project_templates_sample.yaml new file mode 100644 index 00000000..1b071f94 --- /dev/null +++ b/samples/project_templates_sample.yaml @@ -0,0 +1,45 @@ +projecttemplates: + getProjectTemplate: >- + const asana = require('asana'); + + + const client = asana.Client.create().useAccessToken('PERSONAL_ACCESS_TOKEN'); + + + client.projecttemplates.getProjectTemplate(projectTemplateGid, {param: "value", param: "value", opt_pretty: true}) + .then((result) => { + console.log(result); + }); + getProjectTemplates: >- + const asana = require('asana'); + + + const client = asana.Client.create().useAccessToken('PERSONAL_ACCESS_TOKEN'); + + + client.projecttemplates.getProjectTemplates({param: "value", param: "value", opt_pretty: true}) + .then((result) => { + console.log(result); + }); + getProjectTemplatesForTeam: >- + const asana = require('asana'); + + + const client = asana.Client.create().useAccessToken('PERSONAL_ACCESS_TOKEN'); + + + client.projecttemplates.getProjectTemplatesForTeam(teamGid, {param: "value", param: "value", opt_pretty: true}) + .then((result) => { + console.log(result); + }); + instantiateProject: >- + const asana = require('asana'); + + + const client = asana.Client.create().useAccessToken('PERSONAL_ACCESS_TOKEN'); + + + client.projecttemplates.instantiateProject(projectTemplateGid, {field: "value", field: "value", pretty: true}) + .then((result) => { + console.log(result); + }); diff --git a/samples/projects_sample.yaml b/samples/projects_sample.yaml index e4b215d7..f05f2dfc 100644 --- a/samples/projects_sample.yaml +++ b/samples/projects_sample.yaml @@ -153,6 +153,17 @@ projects: .then((result) => { console.log(result); }); + projectSaveAsTemplate: >- + const asana = require('asana'); + + + const client = asana.Client.create().useAccessToken('PERSONAL_ACCESS_TOKEN'); + + + client.projects.projectSaveAsTemplate(projectGid, {field: "value", field: "value", pretty: true}) + .then((result) => { + console.log(result); + }); removeCustomFieldSettingForProject: >- const asana = require('asana');