Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ProjectTemplates resource and add it to Client #155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/com/asana/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class Client {
public Projects projects;
public ProjectStatuses projectStatuses;
public ProjectMemberships projectMemberships;
public ProjectTemplates projectTemplates;
public Sections sections;
public Stories stories;
public Tags tags;
Expand Down Expand Up @@ -122,6 +123,7 @@ public Client(Dispatcher dispatcher, Map<String, Object> options, Map<String, St
this.projects = new Projects(this);
this.projectStatuses = new ProjectStatuses(this);
this.projectMemberships = new ProjectMemberships(this);
this.projectTemplates = new ProjectTemplates(this);
this.sections = new Sections(this);
this.stories = new Stories(this);
this.tags = new Tags(this);
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/asana/models/Job.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.asana.models;

import com.google.gson.annotations.SerializedName;

public class Job extends ResourceWithSubtype {
public String name;

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/asana/resources/ProjectTemplates.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.asana.resources;

import com.asana.Client;
import com.asana.resources.gen.ProjectTemplatesBase;

public class ProjectTemplates extends ProjectTemplatesBase {
/**
* @param client Parent client instance
*/
public ProjectTemplates(Client client) {
super(client);
}
}
97 changes: 80 additions & 17 deletions src/main/java/com/asana/resources/gen/ProjectTemplatesBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class ProjectTemplatesBase extends Resource {
/**
* Get a project template
* Returns the complete project template record for a single project template.
* @param projectTemplateGid Globally unique identifier for the project template. (required)
* @param optFields 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. (optional)
* @param optPretty 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. (optional)
* @param projectTemplateGid Globally unique identifier for the project template. (required)
* @param optFields 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. (optional)
* @param optPretty 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. (optional)
* @return ItemRequest(JsonElement)
* @throws IOException If we fail to call the API, e.g. server error or cannot deserialize the response body
*/
Expand All @@ -37,18 +37,26 @@ public ItemRequest<JsonElement> getProjectTemplate(String projectTemplateGid, Li
return req;
}

/**
* Returns the complete project template record for a single project template.
*
* @param projectTemplateGid Globally unique identifier for the project template.
* @return The complete project template record for a single project template.
* @throws IOException If we fail to call the API, e.g. server error or cannot deserialize the response body.
*/
public ItemRequest<JsonElement> getProjectTemplate(String projectTemplateGid) throws IOException {
return getProjectTemplate(projectTemplateGid, null, false);
}

/**
* Get multiple project templates
* Returns the compact project template records for all project templates in the given team or workspace.
* @param team The team to filter projects on. (optional)
* @param workspace The workspace to filter results on. (optional)
* @param offset 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. &#x27;Note: You can only pass in an offset that was returned to you via a previously paginated request.&#x27; (optional)
* @param limit Results per page. The number of objects to return per page. The value must be between 1 and 100. (optional)
* @param optFields 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. (optional)
* @param optPretty 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. (optional)
* @param team The team to filter projects on. (optional)
* @param workspace The workspace to filter results on. (optional)
* @param offset 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. &#x27;Note: You can only pass in an offset that was returned to you via a previously paginated request.&#x27; (optional)
* @param limit Results per page. The number of objects to return per page. The value must be between 1 and 100. (optional)
* @param optFields 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. (optional)
* @param optPretty 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. (optional)
* @return CollectionRequest(JsonElement)
* @throws IOException If we fail to call the API, e.g. server error or cannot deserialize the response body
*/
Expand All @@ -66,17 +74,26 @@ public CollectionRequest<JsonElement> getProjectTemplates(String team, String wo
return req;
}

/**
* Returns the compact project template records for all project templates in the given team or workspace.
*
* @param team The team to filter projects on.
* @param workspace The workspace to filter results on.
* @return The compact project template records for all project templates in the given team or workspace.
* @throws IOException If we fail to call the API, e.g. server error or cannot deserialize the response body.
*/
public CollectionRequest<JsonElement> getProjectTemplates(String team, String workspace) throws IOException {
return getProjectTemplates(team, workspace, null, (int)Client.DEFAULTS.get("page_size"), null, false);
}

/**
* Get a team&#x27;s project templates
* Returns the compact project template records for all project templates in the team.
* @param teamGid Globally unique identifier for the team. (required)
* @param offset 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. &#x27;Note: You can only pass in an offset that was returned to you via a previously paginated request.&#x27; (optional)
* @param limit Results per page. The number of objects to return per page. The value must be between 1 and 100. (optional)
* @param optFields 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. (optional)
* @param optPretty 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. (optional)
* @param teamGid Globally unique identifier for the team. (required)
* @param offset 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. &#x27;Note: You can only pass in an offset that was returned to you via a previously paginated request.&#x27; (optional)
* @param limit Results per page. The number of objects to return per page. The value must be between 1 and 100. (optional)
* @param optFields 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. (optional)
* @param optPretty 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. (optional)
* @return CollectionRequest(JsonElement)
* @throws IOException If we fail to call the API, e.g. server error or cannot deserialize the response body
*/
Expand All @@ -92,15 +109,23 @@ public CollectionRequest<JsonElement> getProjectTemplatesForTeam(String teamGid,
return req;
}

/**
* Returns the compact project template records for all project templates in the team.
*
* @param teamGid Globally unique identifier for the team.
* @return The compact project template records for all project templates in the team.
* @throws IOException If we fail to call the API, e.g. server error or cannot deserialize the response body.
*/
public CollectionRequest<JsonElement> getProjectTemplatesForTeam(String teamGid) throws IOException {
return getProjectTemplatesForTeam(teamGid, null, (int)Client.DEFAULTS.get("page_size"), null, false);
}

/**
* Instantiate a project from a project template
* Creates and returns a job that will asynchronously handle the project instantiation. _Note: The body of this request will differ if your workspace is an organization. To determine if your workspace is an organization, use the [is_organization](/docs/workspace) parameter._
* @param projectTemplateGid Globally unique identifier for the project template. (required)
* @param optFields 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. (optional)
* @param optPretty 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. (optional)
* @param projectTemplateGid Globally unique identifier for the project template. (required)
* @param optFields 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. (optional)
* @param optPretty 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. (optional)
* @return ItemRequest(Job)
* @throws IOException If we fail to call the API, e.g. server error or cannot deserialize the response body
*/
Expand All @@ -114,7 +139,45 @@ public ItemRequest<Job> instantiateProject(String projectTemplateGid, List<Strin
return req;
}

/**
* Creates and returns a job that will asynchronously handle the project instantiation.
*
* The body of this request will differ if your workspace is an organization. To determine if your workspace is
* an organization, test {@link Workspace#isOrganization}.
*
* @apiNote To form this request, it is recommended to first make a request to get a project template using the
* {@link #getProjectTemplate(String)} method or its overloads. Then, from the response, copy the {@code gid}
* from the object in the {@code requested_dates} array and pass it into this method.
*
* @param projectTemplateGid Globally unique identifier for the project template.
* @return A job that will asynchronously handle the project instantiation.
* @throws IOException If we fail to call the API, e.g. server error or cannot deserialize the response body.
*/
public ItemRequest<Job> instantiateProject(String projectTemplateGid) throws IOException {
return instantiateProject(projectTemplateGid, null, false);
}

/**
* Creates and returns a job that will asynchronously handle the project instantiation.
*
* The body of this request will differ if your workspace is an organization. To determine if your workspace is
* an organization, test {@link Workspace#isOrganization}.
*
* @apiNote To form this request, it is recommended to first make a request to get a project template using the
* {@link #getProjectTemplate(String)} method or its overloads. Then, from the response, copy the {@code gid}
* from the object in the {@code requested_dates} array and pass it into this method.
*
* @param projectTemplateGid Globally unique identifier for the project template.
* @param optFields 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.
* @return A job that will asynchronously handle the project instantiation.
* @throws IOException If we fail to call the API, e.g. server error or cannot deserialize the response body.
*/
public ItemRequest<Job> instantiateProject(String projectTemplateGid, List<String> optFields) throws IOException {
return instantiateProject(projectTemplateGid, optFields, false);
}
}