From 7609b17d1465f959eec1353c57acf51915605e47 Mon Sep 17 00:00:00 2001 From: Andrew Wong Date: Mon, 23 Aug 2021 15:12:55 -0700 Subject: [PATCH 1/2] Generated from OpenAPI --- samples/GoalsBaseSample.yaml | 14 +++- samples/TimePeriodsBaseSample.yaml | 21 ++++++ .../com/asana/resources/gen/GoalsBase.java | 35 ++++++++- .../asana/resources/gen/TimePeriodsBase.java | 74 +++++++++++++++++++ 4 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 samples/TimePeriodsBaseSample.yaml create mode 100644 src/main/java/com/asana/resources/gen/TimePeriodsBase.java diff --git a/samples/GoalsBaseSample.yaml b/samples/GoalsBaseSample.yaml index 74428cc..a4bbefc 100644 --- a/samples/GoalsBaseSample.yaml +++ b/samples/GoalsBaseSample.yaml @@ -35,6 +35,18 @@ goalsbase: .data("field", "value") .option("pretty", true) .execute(); + createGoal: >- + import com.asana.Client; + + + Client client = Client.accessToken("PERSONAL_ACCESS_TOKEN"); + + + JsonElement result = client.goals.createGoal() + .data("field", "value") + .data("field", "value") + .option("pretty", true) + .execute(); createGoalMetric: >- import com.asana.Client; @@ -74,7 +86,7 @@ goalsbase: Client client = Client.accessToken("PERSONAL_ACCESS_TOKEN"); - List result = client.goals.getGoals(workspace, team, isWorkspaceLevel, project, portfolio) + List result = client.goals.getGoals(timePeriods, workspace, team, isWorkspaceLevel, project, portfolio) .option("pretty", true) .execute(); getParentGoalsForGoal: >- diff --git a/samples/TimePeriodsBaseSample.yaml b/samples/TimePeriodsBaseSample.yaml new file mode 100644 index 0000000..7aa4c29 --- /dev/null +++ b/samples/TimePeriodsBaseSample.yaml @@ -0,0 +1,21 @@ +timeperiodsbase: + getTimePeriod: >- + import com.asana.Client; + + + Client client = Client.accessToken("PERSONAL_ACCESS_TOKEN"); + + + JsonElement result = client.timeperiods.getTimePeriod(timePeriodGid) + .option("pretty", true) + .execute(); + getTimePeriods: >- + import com.asana.Client; + + + Client client = Client.accessToken("PERSONAL_ACCESS_TOKEN"); + + + List result = client.timeperiods.getTimePeriods(endOn, startOn, workspace) + .option("pretty", true) + .execute(); diff --git a/src/main/java/com/asana/resources/gen/GoalsBase.java b/src/main/java/com/asana/resources/gen/GoalsBase.java index d4a65b0..fc58cf3 100644 --- a/src/main/java/com/asana/resources/gen/GoalsBase.java +++ b/src/main/java/com/asana/resources/gen/GoalsBase.java @@ -82,6 +82,31 @@ public ItemRequest addSupportingWorkForGoal() throws IOException { return addSupportingWorkForGoal(null, false); } /** + * Create a goal + * Creates a new goal in a workspace or team. Returns the full record of the newly created goal. + * @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. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' (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 ItemRequest(JsonElement) + * @throws IOException If we fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ItemRequest createGoal(String offset, Integer limit, List optFields, Boolean optPretty) throws IOException { + String path = "/goals"; + + ItemRequest req = new ItemRequest(this, JsonElement.class, path, "POST") + .query("opt_pretty", optPretty) + .query("opt_fields", optFields) + .query("limit", limit) + .query("offset", offset); + + return req; + } + + public ItemRequest createGoal() throws IOException { + return createGoal(null, (int)Client.DEFAULTS.get("page_size"), null, false); + } + /** * Create a goal metric * Creates and adds a goal metric to a specified goal. Note that this replaces an existing goal metric if one already exists. * @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) @@ -149,6 +174,7 @@ public ItemRequest getGoal(String goalGid) throws IOException { /** * Get goals * Returns compact goal records. + * @param timePeriods Globally unique identifiers for the time periods. (optional) * @param workspace Globally unique identifier for the workspace. (optional) * @param team Globally unique identifier for the team. (optional) * @param isWorkspaceLevel Filter to goals with is_workspace_level set to query value. Must be used with the workspace parameter. (optional) @@ -161,7 +187,7 @@ public ItemRequest getGoal(String goalGid) throws IOException { * @return CollectionRequest(JsonElement) * @throws IOException If we fail to call the API, e.g. server error or cannot deserialize the response body */ - public CollectionRequest getGoals(String workspace, String team, Boolean isWorkspaceLevel, String project, String portfolio, String offset, Integer limit, List optFields, Boolean optPretty) throws IOException { + public CollectionRequest getGoals(List timePeriods, String workspace, String team, Boolean isWorkspaceLevel, String project, String portfolio, String offset, Integer limit, List optFields, Boolean optPretty) throws IOException { String path = "/goals"; CollectionRequest req = new CollectionRequest(this, JsonElement.class, path, "GET") @@ -173,13 +199,14 @@ public CollectionRequest getGoals(String workspace, String team, Bo .query("project", project) .query("is_workspace_level", isWorkspaceLevel) .query("team", team) - .query("workspace", workspace); + .query("workspace", workspace) + .query("time_periods", timePeriods); return req; } - public CollectionRequest getGoals(String workspace, String team, Boolean isWorkspaceLevel, String project, String portfolio) throws IOException { - return getGoals(workspace, team, isWorkspaceLevel, project, portfolio, null, (int)Client.DEFAULTS.get("page_size"), null, false); + public CollectionRequest getGoals(List timePeriods, String workspace, String team, Boolean isWorkspaceLevel, String project, String portfolio) throws IOException { + return getGoals(timePeriods, workspace, team, isWorkspaceLevel, project, portfolio, null, (int)Client.DEFAULTS.get("page_size"), null, false); } /** * Get parent goals from a goal diff --git a/src/main/java/com/asana/resources/gen/TimePeriodsBase.java b/src/main/java/com/asana/resources/gen/TimePeriodsBase.java new file mode 100644 index 0000000..4147bc5 --- /dev/null +++ b/src/main/java/com/asana/resources/gen/TimePeriodsBase.java @@ -0,0 +1,74 @@ +package com.asana.resources.gen; + +import com.asana.Client; +import com.asana.resources.Resource; +import com.asana.requests.ItemRequest; +import com.asana.requests.CollectionRequest; +import com.asana.models.*; +import com.google.gson.JsonElement; + +import java.io.IOException; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.List; + + public class TimePeriodsBase extends Resource { + /** + * @param client Parent client instance + */ + public TimePeriodsBase(Client client) { super(client); } + + /** + * Get a time period + * Returns the full record for a single time period. + * @param timePeriodGid Globally unique identifier for the time period. (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 + */ + public ItemRequest getTimePeriod(String timePeriodGid, List optFields, Boolean optPretty) throws IOException { + String path = "/time_periods/{time_period_gid}".replace("{time_period_gid}", timePeriodGid); + + ItemRequest req = new ItemRequest(this, JsonElement.class, path, "GET") + .query("opt_pretty", optPretty) + .query("opt_fields", optFields); + + return req; + } + + public ItemRequest getTimePeriod(String timePeriodGid) throws IOException { + return getTimePeriod(timePeriodGid, null, false); + } + /** + * Get time periods + * Returns compact time period records. + * @param endOn ISO 8601 date string (optional) + * @param startOn ISO 8601 date string (optional) + * @param workspace Globally unique identifier for the workspace. (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. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' (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 + */ + public CollectionRequest getTimePeriods(LocalDate endOn, LocalDate startOn, String workspace, String offset, Integer limit, List optFields, Boolean optPretty) throws IOException { + String path = "/time_periods"; + + CollectionRequest req = new CollectionRequest(this, JsonElement.class, path, "GET") + .query("opt_pretty", optPretty) + .query("opt_fields", optFields) + .query("limit", limit) + .query("offset", offset) + .query("start_on", startOn) + .query("end_on", endOn) + .query("workspace", workspace); + + return req; + } + + public CollectionRequest getTimePeriods(LocalDate endOn, LocalDate startOn, String workspace) throws IOException { + return getTimePeriods(endOn, startOn, workspace, null, (int)Client.DEFAULTS.get("page_size"), null, false); + } + } From 129f00252562e211b6de66475c0faa45e63b8f99 Mon Sep 17 00:00:00 2001 From: Andrew W <82971401+aw-asana@users.noreply.github.com> Date: Mon, 23 Aug 2021 15:37:19 -0700 Subject: [PATCH 2/2] Update README.md Update version. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ec5c9e4..22a8720 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ If you use [Maven](http://maven.apache.org/) to manage dependencies you can incl com.asana asana - 0.10.6 + 0.10.7 Or, you can build the artifact and install it to your local Maven repository: