From 86491383c13bda2b647c35c2010fe6a4db4e1063 Mon Sep 17 00:00:00 2001 From: John Vu Date: Fri, 4 Mar 2022 14:32:04 -0800 Subject: [PATCH] Generated from OpenAPI --- VERSION | 2 +- .../resources/gen/project_templates_base.rb | 73 +++++++++++++++++++ lib/asana/resources/gen/projects_base.rb | 13 ++++ lib/asana/resources/gen/typeahead_base.rb | 2 +- lib/asana/version.rb | 2 +- samples/project_templates_sample.yaml | 41 +++++++++++ samples/projects_sample.yaml | 10 +++ 7 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 lib/asana/resources/gen/project_templates_base.rb create mode 100644 samples/project_templates_sample.yaml diff --git a/VERSION b/VERSION index cd47247..25fb08c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.10.10 \ No newline at end of file +0.10.11 \ No newline at end of file diff --git a/lib/asana/resources/gen/project_templates_base.rb b/lib/asana/resources/gen/project_templates_base.rb new file mode 100644 index 0000000..e547d3e --- /dev/null +++ b/lib/asana/resources/gen/project_templates_base.rb @@ -0,0 +1,73 @@ +### WARNING: This file is auto-generated by our OpenAPI spec. Do not +### edit it manually. + +require_relative '../../resource_includes/response_helper' + +module Asana + module Resources + class ProjectTemplatesBase < Resource + + def self.inherited(base) + Registry.register(base) + end + + class << self + # Get a project template + # + # project_template_gid - [str] (required) Globally unique identifier for the project template. + # options - [Hash] the request I/O options + # > 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. + # > 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. + def get_project_template(client, project_template_gid: required("project_template_gid"), options: {}) + path = "/project_templates/{project_template_gid}" + path["{project_template_gid}"] = project_template_gid + parse(client.get(path, options: options)).first + end + + # Get multiple project templates + # + + # workspace - [str] The workspace to filter results on. + # team - [str] The team to filter projects on. + # options - [Hash] the request I/O options + # > 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.' + # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. + # > 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. + # > 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. + def get_project_templates(client, workspace: nil, team: nil, options: {}) + path = "/project_templates" + params = { workspace: workspace, team: team }.reject { |_,v| v.nil? || Array(v).empty? } + Collection.new(parse(client.get(path, params: params, options: options)), type: Resource, client: client) + end + + # Get a team's project templates + # + # team_gid - [str] (required) Globally unique identifier for the team. + # options - [Hash] the request I/O options + # > 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.' + # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. + # > 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. + # > 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. + def get_project_templates_for_team(client, team_gid: required("team_gid"), options: {}) + path = "/teams/{team_gid}/project_templates" + path["{team_gid}"] = team_gid + Collection.new(parse(client.get(path, options: options)), type: Resource, client: client) + end + + # Instantiate a project from a project template + # + # project_template_gid - [str] (required) Globally unique identifier for the project template. + # options - [Hash] the request I/O options + # > 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. + # > 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. + # data - [Hash] the attributes to POST + def instantiate_project(client, project_template_gid: required("project_template_gid"), options: {}, **data) + path = "/project_templates/{project_template_gid}/instantiateProject" + path["{project_template_gid}"] = project_template_gid + Job.new(parse(client.post(path, body: data, options: options)).first, client: client) + end + + end + end + end +end diff --git a/lib/asana/resources/gen/projects_base.rb b/lib/asana/resources/gen/projects_base.rb index 26ca570..63a5ab0 100644 --- a/lib/asana/resources/gen/projects_base.rb +++ b/lib/asana/resources/gen/projects_base.rb @@ -202,6 +202,19 @@ def get_task_counts_for_project(client, project_gid: required("project_gid"), op parse(client.get(path, options: options)).first end + # Create a project template from a project + # + # project_gid - [str] (required) Globally unique identifier for the project. + # options - [Hash] the request I/O options + # > 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. + # > 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. + # data - [Hash] the attributes to POST + def project_save_as_template(client, project_gid: required("project_gid"), options: {}, **data) + path = "/projects/{project_gid}/saveAsTemplate" + path["{project_gid}"] = project_gid + Job.new(parse(client.post(path, body: data, options: options)).first, client: client) + end + # Remove a custom field from a project # # project_gid - [str] (required) Globally unique identifier for the project. diff --git a/lib/asana/resources/gen/typeahead_base.rb b/lib/asana/resources/gen/typeahead_base.rb index d1bf888..86ea2a4 100644 --- a/lib/asana/resources/gen/typeahead_base.rb +++ b/lib/asana/resources/gen/typeahead_base.rb @@ -15,7 +15,7 @@ class << self # Get objects via typeahead # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. - # resource_type - [str] (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. + # resource_type - [str] (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 - [str] *Deprecated: new integrations should prefer the resource_type field.* # query - [str] 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 - [int] 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/lib/asana/version.rb b/lib/asana/version.rb index 2965433..bb97242 100644 --- a/lib/asana/version.rb +++ b/lib/asana/version.rb @@ -1,5 +1,5 @@ #:nodoc: module Asana # Public: Version of the gem. - VERSION = '0.10.10' + VERSION = '0.10.11' end diff --git a/samples/project_templates_sample.yaml b/samples/project_templates_sample.yaml new file mode 100644 index 0000000..3a20bd6 --- /dev/null +++ b/samples/project_templates_sample.yaml @@ -0,0 +1,41 @@ +projecttemplates: + get_project_template: >- + require 'asana' + + + client = Asana::Client.new do |c| + c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' + end + + + result = client.project_templates.get_project_template(project_template_gid: 'project_template_gid', param: "value", param: "value", options: {pretty: true}) + get_project_templates: >- + require 'asana' + + + client = Asana::Client.new do |c| + c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' + end + + + result = client.project_templates.get_project_templates(param: "value", param: "value", options: {pretty: true}) + get_project_templates_for_team: >- + require 'asana' + + + client = Asana::Client.new do |c| + c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' + end + + + result = client.project_templates.get_project_templates_for_team(team_gid: 'team_gid', param: "value", param: "value", options: {pretty: true}) + instantiate_project: >- + require 'asana' + + + client = Asana::Client.new do |c| + c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' + end + + + result = client.project_templates.instantiate_project(project_template_gid: 'project_template_gid', field: "value", field: "value", options: {pretty: true}) diff --git a/samples/projects_sample.yaml b/samples/projects_sample.yaml index 914906a..4c7370e 100644 --- a/samples/projects_sample.yaml +++ b/samples/projects_sample.yaml @@ -139,6 +139,16 @@ projects: result = client.projects.get_task_counts_for_project(project_gid: 'project_gid', param: "value", param: "value", options: {pretty: true}) + project_save_as_template: >- + require 'asana' + + + client = Asana::Client.new do |c| + c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' + end + + + result = client.projects.project_save_as_template(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) remove_custom_field_setting_for_project: >- require 'asana'