id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
162,900
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.delete
public ItemRequest<Task> delete(String task) { String path = String.format("/tasks/%s", task); return new ItemRequest<Task>(this, Task.class, path, "DELETE"); }
java
public ItemRequest<Task> delete(String task) { String path = String.format("/tasks/%s", task); return new ItemRequest<Task>(this, Task.class, path, "DELETE"); }
[ "public", "ItemRequest", "<", "Task", ">", "delete", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"DELETE\"", ")", ";", "}" ]
A specific, existing task can be deleted by making a DELETE request on the URL for that task. Deleted tasks go into the "trash" of the user making the delete request. Tasks can be recovered from the trash within a period of 30 days; afterward they are completely removed from the system. Returns an empty data record. @param task The task to delete. @return Request object
[ "A", "specific", "existing", "task", "can", "be", "deleted", "by", "making", "a", "DELETE", "request", "on", "the", "URL", "for", "that", "task", ".", "Deleted", "tasks", "go", "into", "the", "trash", "of", "the", "user", "making", "the", "delete", "request", ".", "Tasks", "can", "be", "recovered", "from", "the", "trash", "within", "a", "period", "of", "30", "days", ";", "afterward", "they", "are", "completely", "removed", "from", "the", "system", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L103-L107
162,901
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.findByProject
public CollectionRequest<Task> findByProject(String projectId) { String path = String.format("/projects/%s/tasks", projectId); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
java
public CollectionRequest<Task> findByProject(String projectId) { String path = String.format("/projects/%s/tasks", projectId); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Task", ">", "findByProject", "(", "String", "projectId", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/tasks\"", ",", "projectId", ")", ";", "return", "new", "CollectionRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact task records for all tasks within the given project, ordered by their priority within the project. @param projectId The project in which to search for tasks. @return Request object
[ "Returns", "the", "compact", "task", "records", "for", "all", "tasks", "within", "the", "given", "project", "ordered", "by", "their", "priority", "within", "the", "project", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L116-L120
162,902
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.findByTag
public CollectionRequest<Task> findByTag(String tag) { String path = String.format("/tags/%s/tasks", tag); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
java
public CollectionRequest<Task> findByTag(String tag) { String path = String.format("/tags/%s/tasks", tag); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Task", ">", "findByTag", "(", "String", "tag", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tags/%s/tasks\"", ",", "tag", ")", ";", "return", "new", "CollectionRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact task records for all tasks with the given tag. @param tag The tag in which to search for tasks. @return Request object
[ "Returns", "the", "compact", "task", "records", "for", "all", "tasks", "with", "the", "given", "tag", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L128-L132
162,903
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.getTasksWithTag
public CollectionRequest<Task> getTasksWithTag(String tag) { String path = String.format("/tags/%s/tasks", tag); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
java
public CollectionRequest<Task> getTasksWithTag(String tag) { String path = String.format("/tags/%s/tasks", tag); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Task", ">", "getTasksWithTag", "(", "String", "tag", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tags/%s/tasks\"", ",", "tag", ")", ";", "return", "new", "CollectionRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact task records for all tasks with the given tag. Tasks can have more than one tag at a time. @param tag The tag to fetch tasks from. @return Request object
[ "Returns", "the", "compact", "task", "records", "for", "all", "tasks", "with", "the", "given", "tag", ".", "Tasks", "can", "have", "more", "than", "one", "tag", "at", "a", "time", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L165-L169
162,904
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.dependencies
public ItemRequest<Task> dependencies(String task) { String path = String.format("/tasks/%s/dependencies", task); return new ItemRequest<Task>(this, Task.class, path, "GET"); }
java
public ItemRequest<Task> dependencies(String task) { String path = String.format("/tasks/%s/dependencies", task); return new ItemRequest<Task>(this, Task.class, path, "GET"); }
[ "public", "ItemRequest", "<", "Task", ">", "dependencies", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/dependencies\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact representations of all of the dependencies of a task. @param task The task to get dependencies on. @return Request object
[ "Returns", "the", "compact", "representations", "of", "all", "of", "the", "dependencies", "of", "a", "task", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L189-L193
162,905
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.dependents
public ItemRequest<Task> dependents(String task) { String path = String.format("/tasks/%s/dependents", task); return new ItemRequest<Task>(this, Task.class, path, "GET"); }
java
public ItemRequest<Task> dependents(String task) { String path = String.format("/tasks/%s/dependents", task); return new ItemRequest<Task>(this, Task.class, path, "GET"); }
[ "public", "ItemRequest", "<", "Task", ">", "dependents", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/dependents\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact representations of all of the dependents of a task. @param task The task to get dependents on. @return Request object
[ "Returns", "the", "compact", "representations", "of", "all", "of", "the", "dependents", "of", "a", "task", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L201-L205
162,906
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.removeDependencies
public ItemRequest<Task> removeDependencies(String task) { String path = String.format("/tasks/%s/removeDependencies", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
java
public ItemRequest<Task> removeDependencies(String task) { String path = String.format("/tasks/%s/removeDependencies", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Task", ">", "removeDependencies", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/removeDependencies\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Unlinks a set of dependencies from this task. @param task The task to remove dependencies from. @return Request object
[ "Unlinks", "a", "set", "of", "dependencies", "from", "this", "task", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L239-L243
162,907
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.removeDependents
public ItemRequest<Task> removeDependents(String task) { String path = String.format("/tasks/%s/removeDependents", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
java
public ItemRequest<Task> removeDependents(String task) { String path = String.format("/tasks/%s/removeDependents", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Task", ">", "removeDependents", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/removeDependents\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Unlinks a set of dependents from this task. @param task The task to remove dependents from. @return Request object
[ "Unlinks", "a", "set", "of", "dependents", "from", "this", "task", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L251-L255
162,908
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.addFollowers
public ItemRequest<Task> addFollowers(String task) { String path = String.format("/tasks/%s/addFollowers", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
java
public ItemRequest<Task> addFollowers(String task) { String path = String.format("/tasks/%s/addFollowers", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Task", ">", "addFollowers", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/addFollowers\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Adds each of the specified followers to the task, if they are not already following. Returns the complete, updated record for the affected task. @param task The task to add followers to. @return Request object
[ "Adds", "each", "of", "the", "specified", "followers", "to", "the", "task", "if", "they", "are", "not", "already", "following", ".", "Returns", "the", "complete", "updated", "record", "for", "the", "affected", "task", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L264-L268
162,909
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.removeFollowers
public ItemRequest<Task> removeFollowers(String task) { String path = String.format("/tasks/%s/removeFollowers", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
java
public ItemRequest<Task> removeFollowers(String task) { String path = String.format("/tasks/%s/removeFollowers", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Task", ">", "removeFollowers", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/removeFollowers\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Removes each of the specified followers from the task if they are following. Returns the complete, updated record for the affected task. @param task The task to remove followers from. @return Request object
[ "Removes", "each", "of", "the", "specified", "followers", "from", "the", "task", "if", "they", "are", "following", ".", "Returns", "the", "complete", "updated", "record", "for", "the", "affected", "task", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L277-L281
162,910
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.projects
public CollectionRequest<Task> projects(String task) { String path = String.format("/tasks/%s/projects", task); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
java
public CollectionRequest<Task> projects(String task) { String path = String.format("/tasks/%s/projects", task); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Task", ">", "projects", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/projects\"", ",", "task", ")", ";", "return", "new", "CollectionRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns a compact representation of all of the projects the task is in. @param task The task to get projects on. @return Request object
[ "Returns", "a", "compact", "representation", "of", "all", "of", "the", "projects", "the", "task", "is", "in", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L289-L293
162,911
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.addProject
public ItemRequest<Task> addProject(String task) { String path = String.format("/tasks/%s/addProject", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
java
public ItemRequest<Task> addProject(String task) { String path = String.format("/tasks/%s/addProject", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Task", ">", "addProject", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/addProject\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Adds the task to the specified project, in the optional location specified. If no location arguments are given, the task will be added to the end of the project. `addProject` can also be used to reorder a task within a project or section that already contains it. At most one of `insert_before`, `insert_after`, or `section` should be specified. Inserting into a section in an non-order-dependent way can be done by specifying `section`, otherwise, to insert within a section in a particular place, specify `insert_before` or `insert_after` and a task within the section to anchor the position of this task. Returns an empty data block. @param task The task to add to a project. @return Request object
[ "Adds", "the", "task", "to", "the", "specified", "project", "in", "the", "optional", "location", "specified", ".", "If", "no", "location", "arguments", "are", "given", "the", "task", "will", "be", "added", "to", "the", "end", "of", "the", "project", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L314-L318
162,912
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.removeProject
public ItemRequest<Task> removeProject(String task) { String path = String.format("/tasks/%s/removeProject", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
java
public ItemRequest<Task> removeProject(String task) { String path = String.format("/tasks/%s/removeProject", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Task", ">", "removeProject", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/removeProject\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Removes the task from the specified project. The task will still exist in the system, but it will not be in the project anymore. Returns an empty data block. @param task The task to remove from a project. @return Request object
[ "Removes", "the", "task", "from", "the", "specified", "project", ".", "The", "task", "will", "still", "exist", "in", "the", "system", "but", "it", "will", "not", "be", "in", "the", "project", "anymore", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L329-L333
162,913
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.tags
public CollectionRequest<Task> tags(String task) { String path = String.format("/tasks/%s/tags", task); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
java
public CollectionRequest<Task> tags(String task) { String path = String.format("/tasks/%s/tags", task); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Task", ">", "tags", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/tags\"", ",", "task", ")", ";", "return", "new", "CollectionRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns a compact representation of all of the tags the task has. @param task The task to get tags on. @return Request object
[ "Returns", "a", "compact", "representation", "of", "all", "of", "the", "tags", "the", "task", "has", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L341-L345
162,914
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.addTag
public ItemRequest<Task> addTag(String task) { String path = String.format("/tasks/%s/addTag", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
java
public ItemRequest<Task> addTag(String task) { String path = String.format("/tasks/%s/addTag", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Task", ">", "addTag", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/addTag\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Adds a tag to a task. Returns an empty data block. @param task The task to add a tag to. @return Request object
[ "Adds", "a", "tag", "to", "a", "task", ".", "Returns", "an", "empty", "data", "block", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L353-L357
162,915
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.removeTag
public ItemRequest<Task> removeTag(String task) { String path = String.format("/tasks/%s/removeTag", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
java
public ItemRequest<Task> removeTag(String task) { String path = String.format("/tasks/%s/removeTag", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Task", ">", "removeTag", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/removeTag\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Removes a tag from the task. Returns an empty data block. @param task The task to remove a tag from. @return Request object
[ "Removes", "a", "tag", "from", "the", "task", ".", "Returns", "an", "empty", "data", "block", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L365-L369
162,916
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.subtasks
public CollectionRequest<Task> subtasks(String task) { String path = String.format("/tasks/%s/subtasks", task); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
java
public CollectionRequest<Task> subtasks(String task) { String path = String.format("/tasks/%s/subtasks", task); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Task", ">", "subtasks", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/subtasks\"", ",", "task", ")", ";", "return", "new", "CollectionRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns a compact representation of all of the subtasks of a task. @param task The task to get the subtasks of. @return Request object
[ "Returns", "a", "compact", "representation", "of", "all", "of", "the", "subtasks", "of", "a", "task", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L377-L381
162,917
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.addSubtask
public ItemRequest<Task> addSubtask(String task) { String path = String.format("/tasks/%s/subtasks", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
java
public ItemRequest<Task> addSubtask(String task) { String path = String.format("/tasks/%s/subtasks", task); return new ItemRequest<Task>(this, Task.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Task", ">", "addSubtask", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/subtasks\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Creates a new subtask and adds it to the parent task. Returns the full record for the newly created subtask. @param task The task to add a subtask to. @return Request object
[ "Creates", "a", "new", "subtask", "and", "adds", "it", "to", "the", "parent", "task", ".", "Returns", "the", "full", "record", "for", "the", "newly", "created", "subtask", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L390-L394
162,918
Asana/java-asana
src/main/java/com/asana/resources/gen/TasksBase.java
TasksBase.stories
public CollectionRequest<Task> stories(String task) { String path = String.format("/tasks/%s/stories", task); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
java
public CollectionRequest<Task> stories(String task) { String path = String.format("/tasks/%s/stories", task); return new CollectionRequest<Task>(this, Task.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Task", ">", "stories", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/stories\"", ",", "task", ")", ";", "return", "new", "CollectionRequest", "<", "Task", ">", "(", "this", ",", "Task", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns a compact representation of all of the stories on the task. @param task The task containing the stories to get. @return Request object
[ "Returns", "a", "compact", "representation", "of", "all", "of", "the", "stories", "on", "the", "task", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TasksBase.java#L402-L406
162,919
Asana/java-asana
src/main/java/com/asana/resources/gen/TagsBase.java
TagsBase.createInWorkspace
public ItemRequest<Tag> createInWorkspace(String workspace) { String path = String.format("/workspaces/%s/tags", workspace); return new ItemRequest<Tag>(this, Tag.class, path, "POST"); }
java
public ItemRequest<Tag> createInWorkspace(String workspace) { String path = String.format("/workspaces/%s/tags", workspace); return new ItemRequest<Tag>(this, Tag.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Tag", ">", "createInWorkspace", "(", "String", "workspace", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/workspaces/%s/tags\"", ",", "workspace", ")", ";", "return", "new", "ItemRequest", "<", "Tag", ">", "(", "this", ",", "Tag", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Creates a new tag in a workspace or organization. Every tag is required to be created in a specific workspace or organization, and this cannot be changed once set. Note that you can use the `workspace` parameter regardless of whether or not it is an organization. Returns the full record of the newly created tag. @param workspace The workspace or organization to create the tag in. @return Request object
[ "Creates", "a", "new", "tag", "in", "a", "workspace", "or", "organization", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TagsBase.java#L56-L60
162,920
Asana/java-asana
src/main/java/com/asana/resources/gen/TagsBase.java
TagsBase.findById
public ItemRequest<Tag> findById(String tag) { String path = String.format("/tags/%s", tag); return new ItemRequest<Tag>(this, Tag.class, path, "GET"); }
java
public ItemRequest<Tag> findById(String tag) { String path = String.format("/tags/%s", tag); return new ItemRequest<Tag>(this, Tag.class, path, "GET"); }
[ "public", "ItemRequest", "<", "Tag", ">", "findById", "(", "String", "tag", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tags/%s\"", ",", "tag", ")", ";", "return", "new", "ItemRequest", "<", "Tag", ">", "(", "this", ",", "Tag", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the complete tag record for a single tag. @param tag The tag to get. @return Request object
[ "Returns", "the", "complete", "tag", "record", "for", "a", "single", "tag", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TagsBase.java#L68-L72
162,921
Asana/java-asana
src/main/java/com/asana/resources/gen/TagsBase.java
TagsBase.update
public ItemRequest<Tag> update(String tag) { String path = String.format("/tags/%s", tag); return new ItemRequest<Tag>(this, Tag.class, path, "PUT"); }
java
public ItemRequest<Tag> update(String tag) { String path = String.format("/tags/%s", tag); return new ItemRequest<Tag>(this, Tag.class, path, "PUT"); }
[ "public", "ItemRequest", "<", "Tag", ">", "update", "(", "String", "tag", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tags/%s\"", ",", "tag", ")", ";", "return", "new", "ItemRequest", "<", "Tag", ">", "(", "this", ",", "Tag", ".", "class", ",", "path", ",", "\"PUT\"", ")", ";", "}" ]
Updates the properties of a tag. Only the fields provided in the `data` block will be updated; any unspecified fields will remain unchanged. 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 task. Returns the complete updated tag record. @param tag The tag to update. @return Request object
[ "Updates", "the", "properties", "of", "a", "tag", ".", "Only", "the", "fields", "provided", "in", "the", "data", "block", "will", "be", "updated", ";", "any", "unspecified", "fields", "will", "remain", "unchanged", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TagsBase.java#L87-L91
162,922
Asana/java-asana
src/main/java/com/asana/resources/gen/TagsBase.java
TagsBase.delete
public ItemRequest<Tag> delete(String tag) { String path = String.format("/tags/%s", tag); return new ItemRequest<Tag>(this, Tag.class, path, "DELETE"); }
java
public ItemRequest<Tag> delete(String tag) { String path = String.format("/tags/%s", tag); return new ItemRequest<Tag>(this, Tag.class, path, "DELETE"); }
[ "public", "ItemRequest", "<", "Tag", ">", "delete", "(", "String", "tag", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tags/%s\"", ",", "tag", ")", ";", "return", "new", "ItemRequest", "<", "Tag", ">", "(", "this", ",", "Tag", ".", "class", ",", "path", ",", "\"DELETE\"", ")", ";", "}" ]
A specific, existing tag can be deleted by making a DELETE request on the URL for that tag. Returns an empty data record. @param tag The tag to delete. @return Request object
[ "A", "specific", "existing", "tag", "can", "be", "deleted", "by", "making", "a", "DELETE", "request", "on", "the", "URL", "for", "that", "tag", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TagsBase.java#L102-L106
162,923
Asana/java-asana
src/main/java/com/asana/resources/gen/TagsBase.java
TagsBase.findByWorkspace
public CollectionRequest<Tag> findByWorkspace(String workspace) { String path = String.format("/workspaces/%s/tags", workspace); return new CollectionRequest<Tag>(this, Tag.class, path, "GET"); }
java
public CollectionRequest<Tag> findByWorkspace(String workspace) { String path = String.format("/workspaces/%s/tags", workspace); return new CollectionRequest<Tag>(this, Tag.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Tag", ">", "findByWorkspace", "(", "String", "workspace", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/workspaces/%s/tags\"", ",", "workspace", ")", ";", "return", "new", "CollectionRequest", "<", "Tag", ">", "(", "this", ",", "Tag", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact tag records for all tags in the workspace. @param workspace The workspace or organization to find tags in. @return Request object
[ "Returns", "the", "compact", "tag", "records", "for", "all", "tags", "in", "the", "workspace", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TagsBase.java#L125-L129
162,924
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.createInWorkspace
public ItemRequest<Project> createInWorkspace(String workspace) { String path = String.format("/workspaces/%s/projects", workspace); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
java
public ItemRequest<Project> createInWorkspace(String workspace) { String path = String.format("/workspaces/%s/projects", workspace); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Project", ">", "createInWorkspace", "(", "String", "workspace", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/workspaces/%s/projects\"", ",", "workspace", ")", ";", "return", "new", "ItemRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
If the workspace for your project _is_ an organization, you must also supply a `team` to share the project with. Returns the full record of the newly created project. @param workspace The workspace or organization to create the project in. @return Request object
[ "If", "the", "workspace", "for", "your", "project", "_is_", "an", "organization", "you", "must", "also", "supply", "a", "team", "to", "share", "the", "project", "with", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L57-L61
162,925
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.createInTeam
public ItemRequest<Project> createInTeam(String team) { String path = String.format("/teams/%s/projects", team); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
java
public ItemRequest<Project> createInTeam(String team) { String path = String.format("/teams/%s/projects", team); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Project", ">", "createInTeam", "(", "String", "team", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/teams/%s/projects\"", ",", "team", ")", ";", "return", "new", "ItemRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Creates a project shared with the given team. Returns the full record of the newly created project. @param team The team to create the project in. @return Request object
[ "Creates", "a", "project", "shared", "with", "the", "given", "team", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L71-L75
162,926
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.findById
public ItemRequest<Project> findById(String project) { String path = String.format("/projects/%s", project); return new ItemRequest<Project>(this, Project.class, path, "GET"); }
java
public ItemRequest<Project> findById(String project) { String path = String.format("/projects/%s", project); return new ItemRequest<Project>(this, Project.class, path, "GET"); }
[ "public", "ItemRequest", "<", "Project", ">", "findById", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the complete project record for a single project. @param project The project to get. @return Request object
[ "Returns", "the", "complete", "project", "record", "for", "a", "single", "project", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L83-L87
162,927
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.update
public ItemRequest<Project> update(String project) { String path = String.format("/projects/%s", project); return new ItemRequest<Project>(this, Project.class, path, "PUT"); }
java
public ItemRequest<Project> update(String project) { String path = String.format("/projects/%s", project); return new ItemRequest<Project>(this, Project.class, path, "PUT"); }
[ "public", "ItemRequest", "<", "Project", ">", "update", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"PUT\"", ")", ";", "}" ]
A specific, existing project can be updated by making a PUT request on the URL for that project. Only the fields provided in the `data` block will be updated; any unspecified fields will remain unchanged. 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 task. Returns the complete updated project record. @param project The project to update. @return Request object
[ "A", "specific", "existing", "project", "can", "be", "updated", "by", "making", "a", "PUT", "request", "on", "the", "URL", "for", "that", "project", ".", "Only", "the", "fields", "provided", "in", "the", "data", "block", "will", "be", "updated", ";", "any", "unspecified", "fields", "will", "remain", "unchanged", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L103-L107
162,928
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.delete
public ItemRequest<Project> delete(String project) { String path = String.format("/projects/%s", project); return new ItemRequest<Project>(this, Project.class, path, "DELETE"); }
java
public ItemRequest<Project> delete(String project) { String path = String.format("/projects/%s", project); return new ItemRequest<Project>(this, Project.class, path, "DELETE"); }
[ "public", "ItemRequest", "<", "Project", ">", "delete", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"DELETE\"", ")", ";", "}" ]
A specific, existing project can be deleted by making a DELETE request on the URL for that project. Returns an empty data record. @param project The project to delete. @return Request object
[ "A", "specific", "existing", "project", "can", "be", "deleted", "by", "making", "a", "DELETE", "request", "on", "the", "URL", "for", "that", "project", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L118-L122
162,929
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.findByWorkspace
public CollectionRequest<Project> findByWorkspace(String workspace) { String path = String.format("/workspaces/%s/projects", workspace); return new CollectionRequest<Project>(this, Project.class, path, "GET"); }
java
public CollectionRequest<Project> findByWorkspace(String workspace) { String path = String.format("/workspaces/%s/projects", workspace); return new CollectionRequest<Project>(this, Project.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Project", ">", "findByWorkspace", "(", "String", "workspace", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/workspaces/%s/projects\"", ",", "workspace", ")", ";", "return", "new", "CollectionRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact project records for all projects in the workspace. @param workspace The workspace or organization to find projects in. @return Request object
[ "Returns", "the", "compact", "project", "records", "for", "all", "projects", "in", "the", "workspace", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L141-L145
162,930
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.findByTeam
public CollectionRequest<Project> findByTeam(String team) { String path = String.format("/teams/%s/projects", team); return new CollectionRequest<Project>(this, Project.class, path, "GET"); }
java
public CollectionRequest<Project> findByTeam(String team) { String path = String.format("/teams/%s/projects", team); return new CollectionRequest<Project>(this, Project.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Project", ">", "findByTeam", "(", "String", "team", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/teams/%s/projects\"", ",", "team", ")", ";", "return", "new", "CollectionRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact project records for all projects in the team. @param team The team to find projects in. @return Request object
[ "Returns", "the", "compact", "project", "records", "for", "all", "projects", "in", "the", "team", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L153-L157
162,931
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.tasks
public CollectionRequest<Project> tasks(String project) { String path = String.format("/projects/%s/tasks", project); return new CollectionRequest<Project>(this, Project.class, path, "GET"); }
java
public CollectionRequest<Project> tasks(String project) { String path = String.format("/projects/%s/tasks", project); return new CollectionRequest<Project>(this, Project.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Project", ">", "tasks", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/tasks\"", ",", "project", ")", ";", "return", "new", "CollectionRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact task records for all tasks within the given project, ordered by their priority within the project. Tasks can exist in more than one project at a time. @param project The project in which to search for tasks. @return Request object
[ "Returns", "the", "compact", "task", "records", "for", "all", "tasks", "within", "the", "given", "project", "ordered", "by", "their", "priority", "within", "the", "project", ".", "Tasks", "can", "exist", "in", "more", "than", "one", "project", "at", "a", "time", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L166-L170
162,932
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.addFollowers
public ItemRequest<Project> addFollowers(String project) { String path = String.format("/projects/%s/addFollowers", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
java
public ItemRequest<Project> addFollowers(String project) { String path = String.format("/projects/%s/addFollowers", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Project", ">", "addFollowers", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/addFollowers\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Adds the specified list of users as followers to the project. Followers are a subset of members, therefore if the users are not already members of the project they will also become members as a result of this operation. Returns the updated project record. @param project The project to add followers to. @return Request object
[ "Adds", "the", "specified", "list", "of", "users", "as", "followers", "to", "the", "project", ".", "Followers", "are", "a", "subset", "of", "members", "therefore", "if", "the", "users", "are", "not", "already", "members", "of", "the", "project", "they", "will", "also", "become", "members", "as", "a", "result", "of", "this", "operation", ".", "Returns", "the", "updated", "project", "record", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L180-L184
162,933
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.removeFollowers
public ItemRequest<Project> removeFollowers(String project) { String path = String.format("/projects/%s/removeFollowers", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
java
public ItemRequest<Project> removeFollowers(String project) { String path = String.format("/projects/%s/removeFollowers", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Project", ">", "removeFollowers", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/removeFollowers\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Removes the specified list of users from following the project, this will not affect project membership status. Returns the updated project record. @param project The project to remove followers from. @return Request object
[ "Removes", "the", "specified", "list", "of", "users", "from", "following", "the", "project", "this", "will", "not", "affect", "project", "membership", "status", ".", "Returns", "the", "updated", "project", "record", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L193-L197
162,934
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.addMembers
public ItemRequest<Project> addMembers(String project) { String path = String.format("/projects/%s/addMembers", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
java
public ItemRequest<Project> addMembers(String project) { String path = String.format("/projects/%s/addMembers", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Project", ">", "addMembers", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/addMembers\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Adds the specified list of users as members of the project. Returns the updated project record. @param project The project to add members to. @return Request object
[ "Adds", "the", "specified", "list", "of", "users", "as", "members", "of", "the", "project", ".", "Returns", "the", "updated", "project", "record", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L205-L209
162,935
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.removeMembers
public ItemRequest<Project> removeMembers(String project) { String path = String.format("/projects/%s/removeMembers", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
java
public ItemRequest<Project> removeMembers(String project) { String path = String.format("/projects/%s/removeMembers", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Project", ">", "removeMembers", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/removeMembers\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Removes the specified list of members from the project. Returns the updated project record. @param project The project to remove members from. @return Request object
[ "Removes", "the", "specified", "list", "of", "members", "from", "the", "project", ".", "Returns", "the", "updated", "project", "record", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L217-L221
162,936
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.addCustomFieldSetting
public ItemRequest<Project> addCustomFieldSetting(String project) { String path = String.format("/projects/%s/addCustomFieldSetting", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
java
public ItemRequest<Project> addCustomFieldSetting(String project) { String path = String.format("/projects/%s/addCustomFieldSetting", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Project", ">", "addCustomFieldSetting", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/addCustomFieldSetting\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Create a new custom field setting on the project. @param project The project to associate the custom field with @return Request object
[ "Create", "a", "new", "custom", "field", "setting", "on", "the", "project", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L229-L233
162,937
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectsBase.java
ProjectsBase.removeCustomFieldSetting
public ItemRequest<Project> removeCustomFieldSetting(String project) { String path = String.format("/projects/%s/removeCustomFieldSetting", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
java
public ItemRequest<Project> removeCustomFieldSetting(String project) { String path = String.format("/projects/%s/removeCustomFieldSetting", project); return new ItemRequest<Project>(this, Project.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Project", ">", "removeCustomFieldSetting", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/removeCustomFieldSetting\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "Project", ">", "(", "this", ",", "Project", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Remove a custom field setting on the project. @param project The project to associate the custom field with @return Request object
[ "Remove", "a", "custom", "field", "setting", "on", "the", "project", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectsBase.java#L241-L245
162,938
Asana/java-asana
src/main/java/com/asana/iterator/PageIterator.java
PageIterator.retrieveNextPage
private void retrieveNextPage() { if (this.pageSize < Long.MAX_VALUE || this.itemLimit < Long.MAX_VALUE) { this.request.query("limit", Math.min(this.pageSize, this.itemLimit - this.count)); } else { this.request.query("limit", null); } ResultBodyCollection<T> page = null; try { page = this.getNext(); } catch (IOException exception) { // See comments in hasNext(). this.ioException = exception; } if (page != null) { this.continuation = this.getContinuation(page); if (page.data != null && !page.data.isEmpty()) { this.count += page.data.size(); this.nextData = page.data; } else { this.nextData = null; } } else { this.continuation = null; this.nextData = null; } }
java
private void retrieveNextPage() { if (this.pageSize < Long.MAX_VALUE || this.itemLimit < Long.MAX_VALUE) { this.request.query("limit", Math.min(this.pageSize, this.itemLimit - this.count)); } else { this.request.query("limit", null); } ResultBodyCollection<T> page = null; try { page = this.getNext(); } catch (IOException exception) { // See comments in hasNext(). this.ioException = exception; } if (page != null) { this.continuation = this.getContinuation(page); if (page.data != null && !page.data.isEmpty()) { this.count += page.data.size(); this.nextData = page.data; } else { this.nextData = null; } } else { this.continuation = null; this.nextData = null; } }
[ "private", "void", "retrieveNextPage", "(", ")", "{", "if", "(", "this", ".", "pageSize", "<", "Long", ".", "MAX_VALUE", "||", "this", ".", "itemLimit", "<", "Long", ".", "MAX_VALUE", ")", "{", "this", ".", "request", ".", "query", "(", "\"limit\"", ",", "Math", ".", "min", "(", "this", ".", "pageSize", ",", "this", ".", "itemLimit", "-", "this", ".", "count", ")", ")", ";", "}", "else", "{", "this", ".", "request", ".", "query", "(", "\"limit\"", ",", "null", ")", ";", "}", "ResultBodyCollection", "<", "T", ">", "page", "=", "null", ";", "try", "{", "page", "=", "this", ".", "getNext", "(", ")", ";", "}", "catch", "(", "IOException", "exception", ")", "{", "// See comments in hasNext().", "this", ".", "ioException", "=", "exception", ";", "}", "if", "(", "page", "!=", "null", ")", "{", "this", ".", "continuation", "=", "this", ".", "getContinuation", "(", "page", ")", ";", "if", "(", "page", ".", "data", "!=", "null", "&&", "!", "page", ".", "data", ".", "isEmpty", "(", ")", ")", "{", "this", ".", "count", "+=", "page", ".", "data", ".", "size", "(", ")", ";", "this", ".", "nextData", "=", "page", ".", "data", ";", "}", "else", "{", "this", ".", "nextData", "=", "null", ";", "}", "}", "else", "{", "this", ".", "continuation", "=", "null", ";", "this", ".", "nextData", "=", "null", ";", "}", "}" ]
Retrieve the next page and store the continuation token, the new data, and any IOException that may occur. Note that it is safe to pass null values to {@link CollectionRequest#query(String, Object)}. Method {@link com.asana.Client#request(com.asana.requests.Request)} will not include such options.
[ "Retrieve", "the", "next", "page", "and", "store", "the", "continuation", "token", "the", "new", "data", "and", "any", "IOException", "that", "may", "occur", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/iterator/PageIterator.java#L48-L73
162,939
Asana/java-asana
src/main/java/com/asana/resources/gen/UsersBase.java
UsersBase.findById
public ItemRequest<User> findById(String user) { String path = String.format("/users/%s", user); return new ItemRequest<User>(this, User.class, path, "GET"); }
java
public ItemRequest<User> findById(String user) { String path = String.format("/users/%s", user); return new ItemRequest<User>(this, User.class, path, "GET"); }
[ "public", "ItemRequest", "<", "User", ">", "findById", "(", "String", "user", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/users/%s\"", ",", "user", ")", ";", "return", "new", "ItemRequest", "<", "User", ">", "(", "this", ",", "User", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the full user record for the single user with the provided ID. @param user An identifier for the user. Can be one of an email address, the globally unique identifier for the user, or the keyword `me` to indicate the current user making the request. @return Request object
[ "Returns", "the", "full", "user", "record", "for", "the", "single", "user", "with", "the", "provided", "ID", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/UsersBase.java#L43-L47
162,940
Asana/java-asana
src/main/java/com/asana/resources/gen/UsersBase.java
UsersBase.findByWorkspace
public CollectionRequest<User> findByWorkspace(String workspace) { String path = String.format("/workspaces/%s/users", workspace); return new CollectionRequest<User>(this, User.class, path, "GET"); }
java
public CollectionRequest<User> findByWorkspace(String workspace) { String path = String.format("/workspaces/%s/users", workspace); return new CollectionRequest<User>(this, User.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "User", ">", "findByWorkspace", "(", "String", "workspace", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/workspaces/%s/users\"", ",", "workspace", ")", ";", "return", "new", "CollectionRequest", "<", "User", ">", "(", "this", ",", "User", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the user records for all users in the specified workspace or organization. @param workspace The workspace in which to get users. @return Request object
[ "Returns", "the", "user", "records", "for", "all", "users", "in", "the", "specified", "workspace", "or", "organization", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/UsersBase.java#L56-L60
162,941
Asana/java-asana
src/main/java/com/asana/resources/gen/CustomFieldsBase.java
CustomFieldsBase.findById
public ItemRequest<CustomField> findById(String customField) { String path = String.format("/custom_fields/%s", customField); return new ItemRequest<CustomField>(this, CustomField.class, path, "GET"); }
java
public ItemRequest<CustomField> findById(String customField) { String path = String.format("/custom_fields/%s", customField); return new ItemRequest<CustomField>(this, CustomField.class, path, "GET"); }
[ "public", "ItemRequest", "<", "CustomField", ">", "findById", "(", "String", "customField", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/custom_fields/%s\"", ",", "customField", ")", ";", "return", "new", "ItemRequest", "<", "CustomField", ">", "(", "this", ",", "CustomField", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the complete definition of a custom field's metadata. @param customField Globally unique identifier for the custom field. @return Request object
[ "Returns", "the", "complete", "definition", "of", "a", "custom", "field", "s", "metadata", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/CustomFieldsBase.java#L44-L48
162,942
Asana/java-asana
src/main/java/com/asana/resources/gen/CustomFieldsBase.java
CustomFieldsBase.findByWorkspace
public CollectionRequest<CustomField> findByWorkspace(String workspace) { String path = String.format("/workspaces/%s/custom_fields", workspace); return new CollectionRequest<CustomField>(this, CustomField.class, path, "GET"); }
java
public CollectionRequest<CustomField> findByWorkspace(String workspace) { String path = String.format("/workspaces/%s/custom_fields", workspace); return new CollectionRequest<CustomField>(this, CustomField.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "CustomField", ">", "findByWorkspace", "(", "String", "workspace", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/workspaces/%s/custom_fields\"", ",", "workspace", ")", ";", "return", "new", "CollectionRequest", "<", "CustomField", ">", "(", "this", ",", "CustomField", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns a list of the compact representation of all of the custom fields in a workspace. @param workspace The workspace or organization to find custom field definitions in. @return Request object
[ "Returns", "a", "list", "of", "the", "compact", "representation", "of", "all", "of", "the", "custom", "fields", "in", "a", "workspace", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/CustomFieldsBase.java#L56-L60
162,943
Asana/java-asana
src/main/java/com/asana/resources/gen/CustomFieldsBase.java
CustomFieldsBase.update
public ItemRequest<CustomField> update(String customField) { String path = String.format("/custom_fields/%s", customField); return new ItemRequest<CustomField>(this, CustomField.class, path, "PUT"); }
java
public ItemRequest<CustomField> update(String customField) { String path = String.format("/custom_fields/%s", customField); return new ItemRequest<CustomField>(this, CustomField.class, path, "PUT"); }
[ "public", "ItemRequest", "<", "CustomField", ">", "update", "(", "String", "customField", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/custom_fields/%s\"", ",", "customField", ")", ";", "return", "new", "ItemRequest", "<", "CustomField", ">", "(", "this", ",", "CustomField", ".", "class", ",", "path", ",", "\"PUT\"", ")", ";", "}" ]
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 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. A custom field's `type` cannot be updated. 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`. Returns the complete updated custom field record. @param customField Globally unique identifier for the custom field. @return Request object
[ "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" ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/CustomFieldsBase.java#L76-L80
162,944
Asana/java-asana
src/main/java/com/asana/resources/gen/CustomFieldsBase.java
CustomFieldsBase.delete
public ItemRequest<CustomField> delete(String customField) { String path = String.format("/custom_fields/%s", customField); return new ItemRequest<CustomField>(this, CustomField.class, path, "DELETE"); }
java
public ItemRequest<CustomField> delete(String customField) { String path = String.format("/custom_fields/%s", customField); return new ItemRequest<CustomField>(this, CustomField.class, path, "DELETE"); }
[ "public", "ItemRequest", "<", "CustomField", ">", "delete", "(", "String", "customField", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/custom_fields/%s\"", ",", "customField", ")", ";", "return", "new", "ItemRequest", "<", "CustomField", ">", "(", "this", ",", "CustomField", ".", "class", ",", "path", ",", "\"DELETE\"", ")", ";", "}" ]
A specific, existing custom field can be deleted by making a DELETE request on the URL for that custom field. Returns an empty data record. @param customField Globally unique identifier for the custom field. @return Request object
[ "A", "specific", "existing", "custom", "field", "can", "be", "deleted", "by", "making", "a", "DELETE", "request", "on", "the", "URL", "for", "that", "custom", "field", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/CustomFieldsBase.java#L90-L94
162,945
Asana/java-asana
src/main/java/com/asana/resources/gen/CustomFieldsBase.java
CustomFieldsBase.updateEnumOption
public ItemRequest<CustomField> updateEnumOption(String enumOption) { String path = String.format("/enum_options/%s", enumOption); return new ItemRequest<CustomField>(this, CustomField.class, path, "PUT"); }
java
public ItemRequest<CustomField> updateEnumOption(String enumOption) { String path = String.format("/enum_options/%s", enumOption); return new ItemRequest<CustomField>(this, CustomField.class, path, "PUT"); }
[ "public", "ItemRequest", "<", "CustomField", ">", "updateEnumOption", "(", "String", "enumOption", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/enum_options/%s\"", ",", "enumOption", ")", ";", "return", "new", "ItemRequest", "<", "CustomField", ">", "(", "this", ",", "CustomField", ".", "class", ",", "path", ",", "\"PUT\"", ")", ";", "}" ]
Updates an existing enum option. Enum custom fields require at least one enabled enum option. Returns the full record of the updated enum option. @param enumOption Globally unique identifier for the enum option. @return Request object
[ "Updates", "an", "existing", "enum", "option", ".", "Enum", "custom", "fields", "require", "at", "least", "one", "enabled", "enum", "option", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/CustomFieldsBase.java#L118-L122
162,946
Asana/java-asana
src/main/java/com/asana/resources/gen/CustomFieldsBase.java
CustomFieldsBase.insertEnumOption
public ItemRequest<CustomField> insertEnumOption(String customField) { String path = String.format("/custom_fields/%s/enum_options/insert", customField); return new ItemRequest<CustomField>(this, CustomField.class, path, "POST"); }
java
public ItemRequest<CustomField> insertEnumOption(String customField) { String path = String.format("/custom_fields/%s/enum_options/insert", customField); return new ItemRequest<CustomField>(this, CustomField.class, path, "POST"); }
[ "public", "ItemRequest", "<", "CustomField", ">", "insertEnumOption", "(", "String", "customField", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/custom_fields/%s/enum_options/insert\"", ",", "customField", ")", ";", "return", "new", "ItemRequest", "<", "CustomField", ">", "(", "this", ",", "CustomField", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Moves a particular enum option to be either before or after another specified enum option in the custom field. @param customField Globally unique identifier for the custom field. @return Request object
[ "Moves", "a", "particular", "enum", "option", "to", "be", "either", "before", "or", "after", "another", "specified", "enum", "option", "in", "the", "custom", "field", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/CustomFieldsBase.java#L130-L134
162,947
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectStatusesBase.java
ProjectStatusesBase.createInProject
public ItemRequest<ProjectStatus> createInProject(String project) { String path = String.format("/projects/%s/project_statuses", project); return new ItemRequest<ProjectStatus>(this, ProjectStatus.class, path, "POST"); }
java
public ItemRequest<ProjectStatus> createInProject(String project) { String path = String.format("/projects/%s/project_statuses", project); return new ItemRequest<ProjectStatus>(this, ProjectStatus.class, path, "POST"); }
[ "public", "ItemRequest", "<", "ProjectStatus", ">", "createInProject", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/project_statuses\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "ProjectStatus", ">", "(", "this", ",", "ProjectStatus", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Creates a new status update on the project. Returns the full record of the newly created project status update. @param project The project on which to create a status update. @return Request object
[ "Creates", "a", "new", "status", "update", "on", "the", "project", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectStatusesBase.java#L33-L37
162,948
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectStatusesBase.java
ProjectStatusesBase.findByProject
public CollectionRequest<ProjectStatus> findByProject(String project) { String path = String.format("/projects/%s/project_statuses", project); return new CollectionRequest<ProjectStatus>(this, ProjectStatus.class, path, "GET"); }
java
public CollectionRequest<ProjectStatus> findByProject(String project) { String path = String.format("/projects/%s/project_statuses", project); return new CollectionRequest<ProjectStatus>(this, ProjectStatus.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "ProjectStatus", ">", "findByProject", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/project_statuses\"", ",", "project", ")", ";", "return", "new", "CollectionRequest", "<", "ProjectStatus", ">", "(", "this", ",", "ProjectStatus", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact project status update records for all updates on the project. @param project The project to find status updates for. @return Request object
[ "Returns", "the", "compact", "project", "status", "update", "records", "for", "all", "updates", "on", "the", "project", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectStatusesBase.java#L45-L49
162,949
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectStatusesBase.java
ProjectStatusesBase.findById
public ItemRequest<ProjectStatus> findById(String projectStatus) { String path = String.format("/project_statuses/%s", projectStatus); return new ItemRequest<ProjectStatus>(this, ProjectStatus.class, path, "GET"); }
java
public ItemRequest<ProjectStatus> findById(String projectStatus) { String path = String.format("/project_statuses/%s", projectStatus); return new ItemRequest<ProjectStatus>(this, ProjectStatus.class, path, "GET"); }
[ "public", "ItemRequest", "<", "ProjectStatus", ">", "findById", "(", "String", "projectStatus", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/project_statuses/%s\"", ",", "projectStatus", ")", ";", "return", "new", "ItemRequest", "<", "ProjectStatus", ">", "(", "this", ",", "ProjectStatus", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the complete record for a single status update. @param projectStatus The project status update to get. @return Request object
[ "Returns", "the", "complete", "record", "for", "a", "single", "status", "update", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectStatusesBase.java#L57-L61
162,950
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectStatusesBase.java
ProjectStatusesBase.delete
public ItemRequest<ProjectStatus> delete(String projectStatus) { String path = String.format("/project_statuses/%s", projectStatus); return new ItemRequest<ProjectStatus>(this, ProjectStatus.class, path, "DELETE"); }
java
public ItemRequest<ProjectStatus> delete(String projectStatus) { String path = String.format("/project_statuses/%s", projectStatus); return new ItemRequest<ProjectStatus>(this, ProjectStatus.class, path, "DELETE"); }
[ "public", "ItemRequest", "<", "ProjectStatus", ">", "delete", "(", "String", "projectStatus", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/project_statuses/%s\"", ",", "projectStatus", ")", ";", "return", "new", "ItemRequest", "<", "ProjectStatus", ">", "(", "this", ",", "ProjectStatus", ".", "class", ",", "path", ",", "\"DELETE\"", ")", ";", "}" ]
Deletes a specific, existing project status update. Returns an empty data record. @param projectStatus The project status update to delete. @return Request object
[ "Deletes", "a", "specific", "existing", "project", "status", "update", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectStatusesBase.java#L71-L75
162,951
Asana/java-asana
src/main/java/com/asana/resources/gen/WebhooksBase.java
WebhooksBase.getById
public ItemRequest<Webhook> getById(String webhook) { String path = String.format("/webhooks/%s", webhook); return new ItemRequest<Webhook>(this, Webhook.class, path, "GET"); }
java
public ItemRequest<Webhook> getById(String webhook) { String path = String.format("/webhooks/%s", webhook); return new ItemRequest<Webhook>(this, Webhook.class, path, "GET"); }
[ "public", "ItemRequest", "<", "Webhook", ">", "getById", "(", "String", "webhook", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/webhooks/%s\"", ",", "webhook", ")", ";", "return", "new", "ItemRequest", "<", "Webhook", ">", "(", "this", ",", "Webhook", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the full record for the given webhook. @param webhook The webhook to get. @return Request object
[ "Returns", "the", "full", "record", "for", "the", "given", "webhook", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WebhooksBase.java#L104-L108
162,952
Asana/java-asana
src/main/java/com/asana/resources/gen/WebhooksBase.java
WebhooksBase.deleteById
public ItemRequest<Webhook> deleteById(String webhook) { String path = String.format("/webhooks/%s", webhook); return new ItemRequest<Webhook>(this, Webhook.class, path, "DELETE"); }
java
public ItemRequest<Webhook> deleteById(String webhook) { String path = String.format("/webhooks/%s", webhook); return new ItemRequest<Webhook>(this, Webhook.class, path, "DELETE"); }
[ "public", "ItemRequest", "<", "Webhook", ">", "deleteById", "(", "String", "webhook", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/webhooks/%s\"", ",", "webhook", ")", ";", "return", "new", "ItemRequest", "<", "Webhook", ">", "(", "this", ",", "Webhook", ".", "class", ",", "path", ",", "\"DELETE\"", ")", ";", "}" ]
This method permanently removes a webhook. Note that it may be possible to receive a request that was already in flight after deleting the webhook, but no further requests will be issued. @param webhook The webhook to delete. @return Request object
[ "This", "method", "permanently", "removes", "a", "webhook", ".", "Note", "that", "it", "may", "be", "possible", "to", "receive", "a", "request", "that", "was", "already", "in", "flight", "after", "deleting", "the", "webhook", "but", "no", "further", "requests", "will", "be", "issued", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WebhooksBase.java#L118-L122
162,953
Asana/java-asana
src/main/java/com/asana/resources/Events.java
Events.get
public EventsRequest<Event> get(String resource, String sync) { return new EventsRequest<Event>(this, Event.class, "/events", "GET") .query("resource", resource) .query("sync", sync); }
java
public EventsRequest<Event> get(String resource, String sync) { return new EventsRequest<Event>(this, Event.class, "/events", "GET") .query("resource", resource) .query("sync", sync); }
[ "public", "EventsRequest", "<", "Event", ">", "get", "(", "String", "resource", ",", "String", "sync", ")", "{", "return", "new", "EventsRequest", "<", "Event", ">", "(", "this", ",", "Event", ".", "class", ",", "\"/events\"", ",", "\"GET\"", ")", ".", "query", "(", "\"resource\"", ",", "resource", ")", ".", "query", "(", "\"sync\"", ",", "sync", ")", ";", "}" ]
Returns any events for the given resource ID since the last sync token @param resource Globally unique identifier for the resource. @param sync Sync token provided by a previous call to the events API @return Request object
[ "Returns", "any", "events", "for", "the", "given", "resource", "ID", "since", "the", "last", "sync", "token" ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/Events.java#L20-L24
162,954
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectMembershipsBase.java
ProjectMembershipsBase.findByProject
public CollectionRequest<ProjectMembership> findByProject(String project) { String path = String.format("/projects/%s/project_memberships", project); return new CollectionRequest<ProjectMembership>(this, ProjectMembership.class, path, "GET"); }
java
public CollectionRequest<ProjectMembership> findByProject(String project) { String path = String.format("/projects/%s/project_memberships", project); return new CollectionRequest<ProjectMembership>(this, ProjectMembership.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "ProjectMembership", ">", "findByProject", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/project_memberships\"", ",", "project", ")", ";", "return", "new", "CollectionRequest", "<", "ProjectMembership", ">", "(", "this", ",", "ProjectMembership", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact project membership records for the project. @param project The project for which to fetch memberships. @return Request object
[ "Returns", "the", "compact", "project", "membership", "records", "for", "the", "project", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectMembershipsBase.java#L29-L33
162,955
Asana/java-asana
src/main/java/com/asana/resources/gen/ProjectMembershipsBase.java
ProjectMembershipsBase.findById
public ItemRequest<ProjectMembership> findById(String projectMembership) { String path = String.format("/project_memberships/%s", projectMembership); return new ItemRequest<ProjectMembership>(this, ProjectMembership.class, path, "GET"); }
java
public ItemRequest<ProjectMembership> findById(String projectMembership) { String path = String.format("/project_memberships/%s", projectMembership); return new ItemRequest<ProjectMembership>(this, ProjectMembership.class, path, "GET"); }
[ "public", "ItemRequest", "<", "ProjectMembership", ">", "findById", "(", "String", "projectMembership", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/project_memberships/%s\"", ",", "projectMembership", ")", ";", "return", "new", "ItemRequest", "<", "ProjectMembership", ">", "(", "this", ",", "ProjectMembership", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the project membership record. @param projectMembership Globally unique identifier for the project membership. @return Request object
[ "Returns", "the", "project", "membership", "record", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/ProjectMembershipsBase.java#L41-L45
162,956
Asana/java-asana
src/main/java/com/asana/resources/gen/StoriesBase.java
StoriesBase.findByTask
public CollectionRequest<Story> findByTask(String task) { String path = String.format("/tasks/%s/stories", task); return new CollectionRequest<Story>(this, Story.class, path, "GET"); }
java
public CollectionRequest<Story> findByTask(String task) { String path = String.format("/tasks/%s/stories", task); return new CollectionRequest<Story>(this, Story.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Story", ">", "findByTask", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/stories\"", ",", "task", ")", ";", "return", "new", "CollectionRequest", "<", "Story", ">", "(", "this", ",", "Story", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact records for all stories on the task. @param task Globally unique identifier for the task. @return Request object
[ "Returns", "the", "compact", "records", "for", "all", "stories", "on", "the", "task", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/StoriesBase.java#L32-L36
162,957
Asana/java-asana
src/main/java/com/asana/resources/gen/StoriesBase.java
StoriesBase.findById
public ItemRequest<Story> findById(String story) { String path = String.format("/stories/%s", story); return new ItemRequest<Story>(this, Story.class, path, "GET"); }
java
public ItemRequest<Story> findById(String story) { String path = String.format("/stories/%s", story); return new ItemRequest<Story>(this, Story.class, path, "GET"); }
[ "public", "ItemRequest", "<", "Story", ">", "findById", "(", "String", "story", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/stories/%s\"", ",", "story", ")", ";", "return", "new", "ItemRequest", "<", "Story", ">", "(", "this", ",", "Story", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the full record for a single story. @param story Globally unique identifier for the story. @return Request object
[ "Returns", "the", "full", "record", "for", "a", "single", "story", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/StoriesBase.java#L44-L48
162,958
Asana/java-asana
src/main/java/com/asana/resources/gen/StoriesBase.java
StoriesBase.update
public ItemRequest<Story> update(String story) { String path = String.format("/stories/%s", story); return new ItemRequest<Story>(this, Story.class, path, "PUT"); }
java
public ItemRequest<Story> update(String story) { String path = String.format("/stories/%s", story); return new ItemRequest<Story>(this, Story.class, path, "PUT"); }
[ "public", "ItemRequest", "<", "Story", ">", "update", "(", "String", "story", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/stories/%s\"", ",", "story", ")", ";", "return", "new", "ItemRequest", "<", "Story", ">", "(", "this", ",", "Story", ".", "class", ",", "path", ",", "\"PUT\"", ")", ";", "}" ]
Updates the story and returns the full record for the updated story. Only comment stories can have their text updated, and only comment stories and attachment stories can be pinned. Only one of `text` and `html_text` can be specified. @param story Globally unique identifier for the story. @return Request object
[ "Updates", "the", "story", "and", "returns", "the", "full", "record", "for", "the", "updated", "story", ".", "Only", "comment", "stories", "can", "have", "their", "text", "updated", "and", "only", "comment", "stories", "and", "attachment", "stories", "can", "be", "pinned", ".", "Only", "one", "of", "text", "and", "html_text", "can", "be", "specified", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/StoriesBase.java#L74-L78
162,959
Asana/java-asana
src/main/java/com/asana/resources/gen/StoriesBase.java
StoriesBase.delete
public ItemRequest<Story> delete(String story) { String path = String.format("/stories/%s", story); return new ItemRequest<Story>(this, Story.class, path, "DELETE"); }
java
public ItemRequest<Story> delete(String story) { String path = String.format("/stories/%s", story); return new ItemRequest<Story>(this, Story.class, path, "DELETE"); }
[ "public", "ItemRequest", "<", "Story", ">", "delete", "(", "String", "story", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/stories/%s\"", ",", "story", ")", ";", "return", "new", "ItemRequest", "<", "Story", ">", "(", "this", ",", "Story", ".", "class", ",", "path", ",", "\"DELETE\"", ")", ";", "}" ]
Deletes a story. A user can only delete stories they have created. Returns an empty data record. @param story Globally unique identifier for the story. @return Request object
[ "Deletes", "a", "story", ".", "A", "user", "can", "only", "delete", "stories", "they", "have", "created", ".", "Returns", "an", "empty", "data", "record", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/StoriesBase.java#L86-L90
162,960
Asana/java-asana
src/main/java/com/asana/resources/gen/WorkspacesBase.java
WorkspacesBase.findById
public ItemRequest<Workspace> findById(String workspace) { String path = String.format("/workspaces/%s", workspace); return new ItemRequest<Workspace>(this, Workspace.class, path, "GET"); }
java
public ItemRequest<Workspace> findById(String workspace) { String path = String.format("/workspaces/%s", workspace); return new ItemRequest<Workspace>(this, Workspace.class, path, "GET"); }
[ "public", "ItemRequest", "<", "Workspace", ">", "findById", "(", "String", "workspace", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/workspaces/%s\"", ",", "workspace", ")", ";", "return", "new", "ItemRequest", "<", "Workspace", ">", "(", "this", ",", "Workspace", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the full workspace record for a single workspace. @param workspace Globally unique identifier for the workspace or organization. @return Request object
[ "Returns", "the", "full", "workspace", "record", "for", "a", "single", "workspace", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WorkspacesBase.java#L39-L43
162,961
Asana/java-asana
src/main/java/com/asana/resources/gen/WorkspacesBase.java
WorkspacesBase.update
public ItemRequest<Workspace> update(String workspace) { String path = String.format("/workspaces/%s", workspace); return new ItemRequest<Workspace>(this, Workspace.class, path, "PUT"); }
java
public ItemRequest<Workspace> update(String workspace) { String path = String.format("/workspaces/%s", workspace); return new ItemRequest<Workspace>(this, Workspace.class, path, "PUT"); }
[ "public", "ItemRequest", "<", "Workspace", ">", "update", "(", "String", "workspace", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/workspaces/%s\"", ",", "workspace", ")", ";", "return", "new", "ItemRequest", "<", "Workspace", ">", "(", "this", ",", "Workspace", ".", "class", ",", "path", ",", "\"PUT\"", ")", ";", "}" ]
A specific, existing workspace can be updated by making a PUT request on the URL for that workspace. Only the fields provided in the data block will be updated; any unspecified fields will remain unchanged. Currently the only field that can be modified for a workspace is its `name`. Returns the complete, updated workspace record. @param workspace The workspace to update. @return Request object
[ "A", "specific", "existing", "workspace", "can", "be", "updated", "by", "making", "a", "PUT", "request", "on", "the", "URL", "for", "that", "workspace", ".", "Only", "the", "fields", "provided", "in", "the", "data", "block", "will", "be", "updated", ";", "any", "unspecified", "fields", "will", "remain", "unchanged", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WorkspacesBase.java#L67-L71
162,962
Asana/java-asana
src/main/java/com/asana/resources/gen/WorkspacesBase.java
WorkspacesBase.addUser
public ItemRequest<Workspace> addUser(String workspace) { String path = String.format("/workspaces/%s/addUser", workspace); return new ItemRequest<Workspace>(this, Workspace.class, path, "POST"); }
java
public ItemRequest<Workspace> addUser(String workspace) { String path = String.format("/workspaces/%s/addUser", workspace); return new ItemRequest<Workspace>(this, Workspace.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Workspace", ">", "addUser", "(", "String", "workspace", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/workspaces/%s/addUser\"", ",", "workspace", ")", ";", "return", "new", "ItemRequest", "<", "Workspace", ">", "(", "this", ",", "Workspace", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
The user can be referenced by their globally unique user ID or their email address. Returns the full user record for the invited user. @param workspace The workspace or organization to invite the user to. @return Request object
[ "The", "user", "can", "be", "referenced", "by", "their", "globally", "unique", "user", "ID", "or", "their", "email", "address", ".", "Returns", "the", "full", "user", "record", "for", "the", "invited", "user", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WorkspacesBase.java#L96-L100
162,963
Asana/java-asana
src/main/java/com/asana/resources/gen/WorkspacesBase.java
WorkspacesBase.removeUser
public ItemRequest<Workspace> removeUser(String workspace) { String path = String.format("/workspaces/%s/removeUser", workspace); return new ItemRequest<Workspace>(this, Workspace.class, path, "POST"); }
java
public ItemRequest<Workspace> removeUser(String workspace) { String path = String.format("/workspaces/%s/removeUser", workspace); return new ItemRequest<Workspace>(this, Workspace.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Workspace", ">", "removeUser", "(", "String", "workspace", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/workspaces/%s/removeUser\"", ",", "workspace", ")", ";", "return", "new", "ItemRequest", "<", "Workspace", ">", "(", "this", ",", "Workspace", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
The user making this call must be an admin in the workspace. Returns an empty data record. @param workspace The workspace or organization to invite the user to. @return Request object
[ "The", "user", "making", "this", "call", "must", "be", "an", "admin", "in", "the", "workspace", ".", "Returns", "an", "empty", "data", "record", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/WorkspacesBase.java#L109-L113
162,964
Asana/java-asana
src/main/java/com/asana/resources/Attachments.java
Attachments.createOnTask
public ItemRequest<Attachment> createOnTask(String task, InputStream fileContent, String fileName, String fileType) { MultipartContent.Part part = new MultipartContent.Part() .setContent(new InputStreamContent(fileType, fileContent)) .setHeaders(new HttpHeaders().set( "Content-Disposition", String.format("form-data; name=\"file\"; filename=\"%s\"", fileName) // TODO: escape fileName? )); MultipartContent content = new MultipartContent() .setMediaType(new HttpMediaType("multipart/form-data").setParameter("boundary", UUID.randomUUID().toString())) .addPart(part); String path = String.format("/tasks/%s/attachments", task); return new ItemRequest<Attachment>(this, Attachment.class, path, "POST") .data(content); }
java
public ItemRequest<Attachment> createOnTask(String task, InputStream fileContent, String fileName, String fileType) { MultipartContent.Part part = new MultipartContent.Part() .setContent(new InputStreamContent(fileType, fileContent)) .setHeaders(new HttpHeaders().set( "Content-Disposition", String.format("form-data; name=\"file\"; filename=\"%s\"", fileName) // TODO: escape fileName? )); MultipartContent content = new MultipartContent() .setMediaType(new HttpMediaType("multipart/form-data").setParameter("boundary", UUID.randomUUID().toString())) .addPart(part); String path = String.format("/tasks/%s/attachments", task); return new ItemRequest<Attachment>(this, Attachment.class, path, "POST") .data(content); }
[ "public", "ItemRequest", "<", "Attachment", ">", "createOnTask", "(", "String", "task", ",", "InputStream", "fileContent", ",", "String", "fileName", ",", "String", "fileType", ")", "{", "MultipartContent", ".", "Part", "part", "=", "new", "MultipartContent", ".", "Part", "(", ")", ".", "setContent", "(", "new", "InputStreamContent", "(", "fileType", ",", "fileContent", ")", ")", ".", "setHeaders", "(", "new", "HttpHeaders", "(", ")", ".", "set", "(", "\"Content-Disposition\"", ",", "String", ".", "format", "(", "\"form-data; name=\\\"file\\\"; filename=\\\"%s\\\"\"", ",", "fileName", ")", "// TODO: escape fileName?", ")", ")", ";", "MultipartContent", "content", "=", "new", "MultipartContent", "(", ")", ".", "setMediaType", "(", "new", "HttpMediaType", "(", "\"multipart/form-data\"", ")", ".", "setParameter", "(", "\"boundary\"", ",", "UUID", ".", "randomUUID", "(", ")", ".", "toString", "(", ")", ")", ")", ".", "addPart", "(", "part", ")", ";", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/attachments\"", ",", "task", ")", ";", "return", "new", "ItemRequest", "<", "Attachment", ">", "(", "this", ",", "Attachment", ".", "class", ",", "path", ",", "\"POST\"", ")", ".", "data", "(", "content", ")", ";", "}" ]
Upload a file and attach it to a task @param task Globally unique identifier for the task. @param fileContent Content of the file to be uploaded @param fileName Name of the file to be uploaded @param fileType MIME type of the file to be uploaded @return Request object
[ "Upload", "a", "file", "and", "attach", "it", "to", "a", "task" ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/Attachments.java#L29-L43
162,965
Asana/java-asana
src/main/java/com/asana/resources/gen/OrganizationExportsBase.java
OrganizationExportsBase.findById
public ItemRequest<OrganizationExport> findById(String organizationExport) { String path = String.format("/organization_exports/%s", organizationExport); return new ItemRequest<OrganizationExport>(this, OrganizationExport.class, path, "GET"); }
java
public ItemRequest<OrganizationExport> findById(String organizationExport) { String path = String.format("/organization_exports/%s", organizationExport); return new ItemRequest<OrganizationExport>(this, OrganizationExport.class, path, "GET"); }
[ "public", "ItemRequest", "<", "OrganizationExport", ">", "findById", "(", "String", "organizationExport", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/organization_exports/%s\"", ",", "organizationExport", ")", ";", "return", "new", "ItemRequest", "<", "OrganizationExport", ">", "(", "this", ",", "OrganizationExport", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns details of a previously-requested Organization export. @param organizationExport Globally unique identifier for the Organization export. @return Request object
[ "Returns", "details", "of", "a", "previously", "-", "requested", "Organization", "export", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/OrganizationExportsBase.java#L37-L41
162,966
Asana/java-asana
src/main/java/com/asana/requests/Request.java
Request.option
public Request option(String key, Object value) { this.options.put(key, value); return this; }
java
public Request option(String key, Object value) { this.options.put(key, value); return this; }
[ "public", "Request", "option", "(", "String", "key", ",", "Object", "value", ")", "{", "this", ".", "options", ".", "put", "(", "key", ",", "value", ")", ";", "return", "this", ";", "}" ]
Sets a client option per-request @param key Option name @param value Option value @return The request itself
[ "Sets", "a", "client", "option", "per", "-", "request" ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/requests/Request.java#L114-L117
162,967
Asana/java-asana
src/main/java/com/asana/requests/Request.java
Request.header
public Request header(String key, String value) { this.headers.put(key, value); return this; }
java
public Request header(String key, String value) { this.headers.put(key, value); return this; }
[ "public", "Request", "header", "(", "String", "key", ",", "String", "value", ")", "{", "this", ".", "headers", ".", "put", "(", "key", ",", "value", ")", ";", "return", "this", ";", "}" ]
Sets a header per-request @param key Header key @param value Header value @return The request itself
[ "Sets", "a", "header", "per", "-", "request" ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/requests/Request.java#L126-L129
162,968
Asana/java-asana
src/main/java/com/asana/resources/gen/AttachmentsBase.java
AttachmentsBase.findById
public ItemRequest<Attachment> findById(String attachment) { String path = String.format("/attachments/%s", attachment); return new ItemRequest<Attachment>(this, Attachment.class, path, "GET"); }
java
public ItemRequest<Attachment> findById(String attachment) { String path = String.format("/attachments/%s", attachment); return new ItemRequest<Attachment>(this, Attachment.class, path, "GET"); }
[ "public", "ItemRequest", "<", "Attachment", ">", "findById", "(", "String", "attachment", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/attachments/%s\"", ",", "attachment", ")", ";", "return", "new", "ItemRequest", "<", "Attachment", ">", "(", "this", ",", "Attachment", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the full record for a single attachment. @param attachment Globally unique identifier for the attachment. @return Request object
[ "Returns", "the", "full", "record", "for", "a", "single", "attachment", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/AttachmentsBase.java#L28-L32
162,969
Asana/java-asana
src/main/java/com/asana/resources/gen/AttachmentsBase.java
AttachmentsBase.findByTask
public CollectionRequest<Attachment> findByTask(String task) { String path = String.format("/tasks/%s/attachments", task); return new CollectionRequest<Attachment>(this, Attachment.class, path, "GET"); }
java
public CollectionRequest<Attachment> findByTask(String task) { String path = String.format("/tasks/%s/attachments", task); return new CollectionRequest<Attachment>(this, Attachment.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Attachment", ">", "findByTask", "(", "String", "task", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/tasks/%s/attachments\"", ",", "task", ")", ";", "return", "new", "CollectionRequest", "<", "Attachment", ">", "(", "this", ",", "Attachment", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact records for all attachments on the task. @param task Globally unique identifier for the task. @return Request object
[ "Returns", "the", "compact", "records", "for", "all", "attachments", "on", "the", "task", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/AttachmentsBase.java#L40-L44
162,970
Asana/java-asana
src/main/java/com/asana/resources/gen/SectionsBase.java
SectionsBase.createInProject
public ItemRequest<Section> createInProject(String project) { String path = String.format("/projects/%s/sections", project); return new ItemRequest<Section>(this, Section.class, path, "POST"); }
java
public ItemRequest<Section> createInProject(String project) { String path = String.format("/projects/%s/sections", project); return new ItemRequest<Section>(this, Section.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Section", ">", "createInProject", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/sections\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "Section", ">", "(", "this", ",", "Section", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Creates a new section in a project. Returns the full record of the newly created section. @param project The project to create the section in @return Request object
[ "Creates", "a", "new", "section", "in", "a", "project", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/SectionsBase.java#L30-L34
162,971
Asana/java-asana
src/main/java/com/asana/resources/gen/SectionsBase.java
SectionsBase.findByProject
public CollectionRequest<Section> findByProject(String project) { String path = String.format("/projects/%s/sections", project); return new CollectionRequest<Section>(this, Section.class, path, "GET"); }
java
public CollectionRequest<Section> findByProject(String project) { String path = String.format("/projects/%s/sections", project); return new CollectionRequest<Section>(this, Section.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Section", ">", "findByProject", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/sections\"", ",", "project", ")", ";", "return", "new", "CollectionRequest", "<", "Section", ">", "(", "this", ",", "Section", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact records for all sections in the specified project. @param project The project to get sections from. @return Request object
[ "Returns", "the", "compact", "records", "for", "all", "sections", "in", "the", "specified", "project", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/SectionsBase.java#L42-L46
162,972
Asana/java-asana
src/main/java/com/asana/resources/gen/SectionsBase.java
SectionsBase.findById
public ItemRequest<Section> findById(String section) { String path = String.format("/sections/%s", section); return new ItemRequest<Section>(this, Section.class, path, "GET"); }
java
public ItemRequest<Section> findById(String section) { String path = String.format("/sections/%s", section); return new ItemRequest<Section>(this, Section.class, path, "GET"); }
[ "public", "ItemRequest", "<", "Section", ">", "findById", "(", "String", "section", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/sections/%s\"", ",", "section", ")", ";", "return", "new", "ItemRequest", "<", "Section", ">", "(", "this", ",", "Section", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the complete record for a single section. @param section The section to get. @return Request object
[ "Returns", "the", "complete", "record", "for", "a", "single", "section", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/SectionsBase.java#L54-L58
162,973
Asana/java-asana
src/main/java/com/asana/resources/gen/SectionsBase.java
SectionsBase.delete
public ItemRequest<Section> delete(String section) { String path = String.format("/sections/%s", section); return new ItemRequest<Section>(this, Section.class, path, "DELETE"); }
java
public ItemRequest<Section> delete(String section) { String path = String.format("/sections/%s", section); return new ItemRequest<Section>(this, Section.class, path, "DELETE"); }
[ "public", "ItemRequest", "<", "Section", ">", "delete", "(", "String", "section", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/sections/%s\"", ",", "section", ")", ";", "return", "new", "ItemRequest", "<", "Section", ">", "(", "this", ",", "Section", ".", "class", ",", "path", ",", "\"DELETE\"", ")", ";", "}" ]
A specific, existing section can be deleted by making a DELETE request on the URL for that section. Note that sections must be empty to be deleted. The last remaining section in a board view cannot be deleted. Returns an empty data block. @param section The section to delete. @return Request object
[ "A", "specific", "existing", "section", "can", "be", "deleted", "by", "making", "a", "DELETE", "request", "on", "the", "URL", "for", "that", "section", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/SectionsBase.java#L94-L98
162,974
Asana/java-asana
src/main/java/com/asana/resources/gen/SectionsBase.java
SectionsBase.insertInProject
public ItemRequest<Section> insertInProject(String project) { String path = String.format("/projects/%s/sections/insert", project); return new ItemRequest<Section>(this, Section.class, path, "POST"); }
java
public ItemRequest<Section> insertInProject(String project) { String path = String.format("/projects/%s/sections/insert", project); return new ItemRequest<Section>(this, Section.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Section", ">", "insertInProject", "(", "String", "project", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/projects/%s/sections/insert\"", ",", "project", ")", ";", "return", "new", "ItemRequest", "<", "Section", ">", "(", "this", ",", "Section", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
Move sections relative to each other in a board view. One of `before_section` or `after_section` is required. Sections cannot be moved between projects. At this point in time, moving sections is not supported in list views, only board views. Returns an empty data block. @param project The project in which to reorder the given section @return Request object
[ "Move", "sections", "relative", "to", "each", "other", "in", "a", "board", "view", ".", "One", "of", "before_section", "or", "after_section", "is", "required", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/SectionsBase.java#L113-L117
162,975
Asana/java-asana
src/main/java/com/asana/resources/gen/TeamsBase.java
TeamsBase.findById
public ItemRequest<Team> findById(String team) { String path = String.format("/teams/%s", team); return new ItemRequest<Team>(this, Team.class, path, "GET"); }
java
public ItemRequest<Team> findById(String team) { String path = String.format("/teams/%s", team); return new ItemRequest<Team>(this, Team.class, path, "GET"); }
[ "public", "ItemRequest", "<", "Team", ">", "findById", "(", "String", "team", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/teams/%s\"", ",", "team", ")", ";", "return", "new", "ItemRequest", "<", "Team", ">", "(", "this", ",", "Team", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the full record for a single team. @param team Globally unique identifier for the team. @return Request object
[ "Returns", "the", "full", "record", "for", "a", "single", "team", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L27-L31
162,976
Asana/java-asana
src/main/java/com/asana/resources/gen/TeamsBase.java
TeamsBase.findByOrganization
public CollectionRequest<Team> findByOrganization(String organization) { String path = String.format("/organizations/%s/teams", organization); return new CollectionRequest<Team>(this, Team.class, path, "GET"); }
java
public CollectionRequest<Team> findByOrganization(String organization) { String path = String.format("/organizations/%s/teams", organization); return new CollectionRequest<Team>(this, Team.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Team", ">", "findByOrganization", "(", "String", "organization", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/organizations/%s/teams\"", ",", "organization", ")", ";", "return", "new", "CollectionRequest", "<", "Team", ">", "(", "this", ",", "Team", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact records for all teams in the organization visible to the authorized user. @param organization Globally unique identifier for the workspace or organization. @return Request object
[ "Returns", "the", "compact", "records", "for", "all", "teams", "in", "the", "organization", "visible", "to", "the", "authorized", "user", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L40-L44
162,977
Asana/java-asana
src/main/java/com/asana/resources/gen/TeamsBase.java
TeamsBase.findByUser
public CollectionRequest<Team> findByUser(String user) { String path = String.format("/users/%s/teams", user); return new CollectionRequest<Team>(this, Team.class, path, "GET"); }
java
public CollectionRequest<Team> findByUser(String user) { String path = String.format("/users/%s/teams", user); return new CollectionRequest<Team>(this, Team.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Team", ">", "findByUser", "(", "String", "user", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/users/%s/teams\"", ",", "user", ")", ";", "return", "new", "CollectionRequest", "<", "Team", ">", "(", "this", ",", "Team", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact records for all teams to which user is assigned. @param user An identifier for the user. Can be one of an email address, the globally unique identifier for the user, or the keyword `me` to indicate the current user making the request. @return Request object
[ "Returns", "the", "compact", "records", "for", "all", "teams", "to", "which", "user", "is", "assigned", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L54-L58
162,978
Asana/java-asana
src/main/java/com/asana/resources/gen/TeamsBase.java
TeamsBase.users
public CollectionRequest<Team> users(String team) { String path = String.format("/teams/%s/users", team); return new CollectionRequest<Team>(this, Team.class, path, "GET"); }
java
public CollectionRequest<Team> users(String team) { String path = String.format("/teams/%s/users", team); return new CollectionRequest<Team>(this, Team.class, path, "GET"); }
[ "public", "CollectionRequest", "<", "Team", ">", "users", "(", "String", "team", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/teams/%s/users\"", ",", "team", ")", ";", "return", "new", "CollectionRequest", "<", "Team", ">", "(", "this", ",", "Team", ".", "class", ",", "path", ",", "\"GET\"", ")", ";", "}" ]
Returns the compact records for all users that are members of the team. @param team Globally unique identifier for the team. @return Request object
[ "Returns", "the", "compact", "records", "for", "all", "users", "that", "are", "members", "of", "the", "team", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L66-L70
162,979
Asana/java-asana
src/main/java/com/asana/resources/gen/TeamsBase.java
TeamsBase.addUser
public ItemRequest<Team> addUser(String team) { String path = String.format("/teams/%s/addUser", team); return new ItemRequest<Team>(this, Team.class, path, "POST"); }
java
public ItemRequest<Team> addUser(String team) { String path = String.format("/teams/%s/addUser", team); return new ItemRequest<Team>(this, Team.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Team", ">", "addUser", "(", "String", "team", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/teams/%s/addUser\"", ",", "team", ")", ";", "return", "new", "ItemRequest", "<", "Team", ">", "(", "this", ",", "Team", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
The user making this call must be a member of the team in order to add others. The user to add must exist in the same organization as the team in order to be added. The user to add can be referenced by their globally unique user ID or their email address. Returns the full user record for the added user. @param team Globally unique identifier for the team. @return Request object
[ "The", "user", "making", "this", "call", "must", "be", "a", "member", "of", "the", "team", "in", "order", "to", "add", "others", ".", "The", "user", "to", "add", "must", "exist", "in", "the", "same", "organization", "as", "the", "team", "in", "order", "to", "be", "added", ".", "The", "user", "to", "add", "can", "be", "referenced", "by", "their", "globally", "unique", "user", "ID", "or", "their", "email", "address", ".", "Returns", "the", "full", "user", "record", "for", "the", "added", "user", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L81-L85
162,980
Asana/java-asana
src/main/java/com/asana/resources/gen/TeamsBase.java
TeamsBase.removeUser
public ItemRequest<Team> removeUser(String team) { String path = String.format("/teams/%s/removeUser", team); return new ItemRequest<Team>(this, Team.class, path, "POST"); }
java
public ItemRequest<Team> removeUser(String team) { String path = String.format("/teams/%s/removeUser", team); return new ItemRequest<Team>(this, Team.class, path, "POST"); }
[ "public", "ItemRequest", "<", "Team", ">", "removeUser", "(", "String", "team", ")", "{", "String", "path", "=", "String", ".", "format", "(", "\"/teams/%s/removeUser\"", ",", "team", ")", ";", "return", "new", "ItemRequest", "<", "Team", ">", "(", "this", ",", "Team", ".", "class", ",", "path", ",", "\"POST\"", ")", ";", "}" ]
The user to remove can be referenced by their globally unique user ID or their email address. Removes the user from the specified team. Returns an empty data record. @param team Globally unique identifier for the team. @return Request object
[ "The", "user", "to", "remove", "can", "be", "referenced", "by", "their", "globally", "unique", "user", "ID", "or", "their", "email", "address", ".", "Removes", "the", "user", "from", "the", "specified", "team", ".", "Returns", "an", "empty", "data", "record", "." ]
abeea92fd5a71260a5d804db4da94e52fd7a15a7
https://github.com/Asana/java-asana/blob/abeea92fd5a71260a5d804db4da94e52fd7a15a7/src/main/java/com/asana/resources/gen/TeamsBase.java#L94-L98
162,981
cdapio/netty-http
src/main/java/io/cdap/http/AbstractHttpHandler.java
AbstractHttpHandler.sendInternalRequest
protected InternalHttpResponse sendInternalRequest(HttpRequest request) { InternalHttpResponder responder = new InternalHttpResponder(); httpResourceHandler.handle(request, responder); return responder.getResponse(); }
java
protected InternalHttpResponse sendInternalRequest(HttpRequest request) { InternalHttpResponder responder = new InternalHttpResponder(); httpResourceHandler.handle(request, responder); return responder.getResponse(); }
[ "protected", "InternalHttpResponse", "sendInternalRequest", "(", "HttpRequest", "request", ")", "{", "InternalHttpResponder", "responder", "=", "new", "InternalHttpResponder", "(", ")", ";", "httpResourceHandler", ".", "handle", "(", "request", ",", "responder", ")", ";", "return", "responder", ".", "getResponse", "(", ")", ";", "}" ]
Send a request to another handler internal to the server, getting back the response body and response code. @param request request to send to another handler. @return {@link InternalHttpResponse} containing the response code and body.
[ "Send", "a", "request", "to", "another", "handler", "internal", "to", "the", "server", "getting", "back", "the", "response", "body", "and", "response", "code", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/AbstractHttpHandler.java#L47-L51
162,982
cdapio/netty-http
src/main/java/io/cdap/http/SSLHandlerFactory.java
SSLHandlerFactory.create
public SslHandler create(ByteBufAllocator bufferAllocator) { SSLEngine engine = sslContext.newEngine(bufferAllocator); engine.setNeedClientAuth(needClientAuth); engine.setUseClientMode(false); return new SslHandler(engine); }
java
public SslHandler create(ByteBufAllocator bufferAllocator) { SSLEngine engine = sslContext.newEngine(bufferAllocator); engine.setNeedClientAuth(needClientAuth); engine.setUseClientMode(false); return new SslHandler(engine); }
[ "public", "SslHandler", "create", "(", "ByteBufAllocator", "bufferAllocator", ")", "{", "SSLEngine", "engine", "=", "sslContext", ".", "newEngine", "(", "bufferAllocator", ")", ";", "engine", ".", "setNeedClientAuth", "(", "needClientAuth", ")", ";", "engine", ".", "setUseClientMode", "(", "false", ")", ";", "return", "new", "SslHandler", "(", "engine", ")", ";", "}" ]
Creates an SslHandler @param bufferAllocator the buffer allocator @return instance of {@code SslHandler}
[ "Creates", "an", "SslHandler" ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/SSLHandlerFactory.java#L86-L91
162,983
cdapio/netty-http
src/main/java/io/cdap/http/internal/HttpResourceHandler.java
HttpResourceHandler.getHttpMethods
private Set<HttpMethod> getHttpMethods(Method method) { Set<HttpMethod> httpMethods = new HashSet<>(); if (method.isAnnotationPresent(GET.class)) { httpMethods.add(HttpMethod.GET); } if (method.isAnnotationPresent(PUT.class)) { httpMethods.add(HttpMethod.PUT); } if (method.isAnnotationPresent(POST.class)) { httpMethods.add(HttpMethod.POST); } if (method.isAnnotationPresent(DELETE.class)) { httpMethods.add(HttpMethod.DELETE); } return Collections.unmodifiableSet(httpMethods); }
java
private Set<HttpMethod> getHttpMethods(Method method) { Set<HttpMethod> httpMethods = new HashSet<>(); if (method.isAnnotationPresent(GET.class)) { httpMethods.add(HttpMethod.GET); } if (method.isAnnotationPresent(PUT.class)) { httpMethods.add(HttpMethod.PUT); } if (method.isAnnotationPresent(POST.class)) { httpMethods.add(HttpMethod.POST); } if (method.isAnnotationPresent(DELETE.class)) { httpMethods.add(HttpMethod.DELETE); } return Collections.unmodifiableSet(httpMethods); }
[ "private", "Set", "<", "HttpMethod", ">", "getHttpMethods", "(", "Method", "method", ")", "{", "Set", "<", "HttpMethod", ">", "httpMethods", "=", "new", "HashSet", "<>", "(", ")", ";", "if", "(", "method", ".", "isAnnotationPresent", "(", "GET", ".", "class", ")", ")", "{", "httpMethods", ".", "add", "(", "HttpMethod", ".", "GET", ")", ";", "}", "if", "(", "method", ".", "isAnnotationPresent", "(", "PUT", ".", "class", ")", ")", "{", "httpMethods", ".", "add", "(", "HttpMethod", ".", "PUT", ")", ";", "}", "if", "(", "method", ".", "isAnnotationPresent", "(", "POST", ".", "class", ")", ")", "{", "httpMethods", ".", "add", "(", "HttpMethod", ".", "POST", ")", ";", "}", "if", "(", "method", ".", "isAnnotationPresent", "(", "DELETE", ".", "class", ")", ")", "{", "httpMethods", ".", "add", "(", "HttpMethod", ".", "DELETE", ")", ";", "}", "return", "Collections", ".", "unmodifiableSet", "(", "httpMethods", ")", ";", "}" ]
Fetches the HttpMethod from annotations and returns String representation of HttpMethod. Return emptyString if not present. @param method Method handling the http request. @return String representation of HttpMethod from annotations or emptyString as a default.
[ "Fetches", "the", "HttpMethod", "from", "annotations", "and", "returns", "String", "representation", "of", "HttpMethod", ".", "Return", "emptyString", "if", "not", "present", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceHandler.java#L137-L154
162,984
cdapio/netty-http
src/main/java/io/cdap/http/internal/HttpResourceHandler.java
HttpResourceHandler.handle
public void handle(HttpRequest request, HttpResponder responder) { if (urlRewriter != null) { try { request.setUri(URI.create(request.uri()).normalize().toString()); if (!urlRewriter.rewrite(request, responder)) { return; } } catch (Throwable t) { responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR, String.format("Caught exception processing request. Reason: %s", t.getMessage())); LOG.error("Exception thrown during rewriting of uri {}", request.uri(), t); return; } } try { String path = URI.create(request.uri()).normalize().getPath(); List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> routableDestinations = patternRouter.getDestinations(path); PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel> matchedDestination = getMatchedDestination(routableDestinations, request.method(), path); if (matchedDestination != null) { //Found a httpresource route to it. HttpResourceModel httpResourceModel = matchedDestination.getDestination(); // Call preCall method of handler hooks. boolean terminated = false; HandlerInfo info = new HandlerInfo(httpResourceModel.getMethod().getDeclaringClass().getName(), httpResourceModel.getMethod().getName()); for (HandlerHook hook : handlerHooks) { if (!hook.preCall(request, responder, info)) { // Terminate further request processing if preCall returns false. terminated = true; break; } } // Call httpresource method if (!terminated) { // Wrap responder to make post hook calls. responder = new WrappedHttpResponder(responder, handlerHooks, request, info); if (httpResourceModel.handle(request, responder, matchedDestination.getGroupNameValues()).isStreaming()) { responder.sendString(HttpResponseStatus.METHOD_NOT_ALLOWED, String.format("Body Consumer not supported for internalHttpResponder: %s", request.uri())); } } } else if (routableDestinations.size() > 0) { //Found a matching resource but could not find the right HttpMethod so return 405 responder.sendString(HttpResponseStatus.METHOD_NOT_ALLOWED, String.format("Problem accessing: %s. Reason: Method Not Allowed", request.uri())); } else { responder.sendString(HttpResponseStatus.NOT_FOUND, String.format("Problem accessing: %s. Reason: Not Found", request.uri())); } } catch (Throwable t) { responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR, String.format("Caught exception processing request. Reason: %s", t.getMessage())); LOG.error("Exception thrown during request processing for uri {}", request.uri(), t); } }
java
public void handle(HttpRequest request, HttpResponder responder) { if (urlRewriter != null) { try { request.setUri(URI.create(request.uri()).normalize().toString()); if (!urlRewriter.rewrite(request, responder)) { return; } } catch (Throwable t) { responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR, String.format("Caught exception processing request. Reason: %s", t.getMessage())); LOG.error("Exception thrown during rewriting of uri {}", request.uri(), t); return; } } try { String path = URI.create(request.uri()).normalize().getPath(); List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> routableDestinations = patternRouter.getDestinations(path); PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel> matchedDestination = getMatchedDestination(routableDestinations, request.method(), path); if (matchedDestination != null) { //Found a httpresource route to it. HttpResourceModel httpResourceModel = matchedDestination.getDestination(); // Call preCall method of handler hooks. boolean terminated = false; HandlerInfo info = new HandlerInfo(httpResourceModel.getMethod().getDeclaringClass().getName(), httpResourceModel.getMethod().getName()); for (HandlerHook hook : handlerHooks) { if (!hook.preCall(request, responder, info)) { // Terminate further request processing if preCall returns false. terminated = true; break; } } // Call httpresource method if (!terminated) { // Wrap responder to make post hook calls. responder = new WrappedHttpResponder(responder, handlerHooks, request, info); if (httpResourceModel.handle(request, responder, matchedDestination.getGroupNameValues()).isStreaming()) { responder.sendString(HttpResponseStatus.METHOD_NOT_ALLOWED, String.format("Body Consumer not supported for internalHttpResponder: %s", request.uri())); } } } else if (routableDestinations.size() > 0) { //Found a matching resource but could not find the right HttpMethod so return 405 responder.sendString(HttpResponseStatus.METHOD_NOT_ALLOWED, String.format("Problem accessing: %s. Reason: Method Not Allowed", request.uri())); } else { responder.sendString(HttpResponseStatus.NOT_FOUND, String.format("Problem accessing: %s. Reason: Not Found", request.uri())); } } catch (Throwable t) { responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR, String.format("Caught exception processing request. Reason: %s", t.getMessage())); LOG.error("Exception thrown during request processing for uri {}", request.uri(), t); } }
[ "public", "void", "handle", "(", "HttpRequest", "request", ",", "HttpResponder", "responder", ")", "{", "if", "(", "urlRewriter", "!=", "null", ")", "{", "try", "{", "request", ".", "setUri", "(", "URI", ".", "create", "(", "request", ".", "uri", "(", ")", ")", ".", "normalize", "(", ")", ".", "toString", "(", ")", ")", ";", "if", "(", "!", "urlRewriter", ".", "rewrite", "(", "request", ",", "responder", ")", ")", "{", "return", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "responder", ".", "sendString", "(", "HttpResponseStatus", ".", "INTERNAL_SERVER_ERROR", ",", "String", ".", "format", "(", "\"Caught exception processing request. Reason: %s\"", ",", "t", ".", "getMessage", "(", ")", ")", ")", ";", "LOG", ".", "error", "(", "\"Exception thrown during rewriting of uri {}\"", ",", "request", ".", "uri", "(", ")", ",", "t", ")", ";", "return", ";", "}", "}", "try", "{", "String", "path", "=", "URI", ".", "create", "(", "request", ".", "uri", "(", ")", ")", ".", "normalize", "(", ")", ".", "getPath", "(", ")", ";", "List", "<", "PatternPathRouterWithGroups", ".", "RoutableDestination", "<", "HttpResourceModel", ">", ">", "routableDestinations", "=", "patternRouter", ".", "getDestinations", "(", "path", ")", ";", "PatternPathRouterWithGroups", ".", "RoutableDestination", "<", "HttpResourceModel", ">", "matchedDestination", "=", "getMatchedDestination", "(", "routableDestinations", ",", "request", ".", "method", "(", ")", ",", "path", ")", ";", "if", "(", "matchedDestination", "!=", "null", ")", "{", "//Found a httpresource route to it.", "HttpResourceModel", "httpResourceModel", "=", "matchedDestination", ".", "getDestination", "(", ")", ";", "// Call preCall method of handler hooks.", "boolean", "terminated", "=", "false", ";", "HandlerInfo", "info", "=", "new", "HandlerInfo", "(", "httpResourceModel", ".", "getMethod", "(", ")", ".", "getDeclaringClass", "(", ")", ".", "getName", "(", ")", ",", "httpResourceModel", ".", "getMethod", "(", ")", ".", "getName", "(", ")", ")", ";", "for", "(", "HandlerHook", "hook", ":", "handlerHooks", ")", "{", "if", "(", "!", "hook", ".", "preCall", "(", "request", ",", "responder", ",", "info", ")", ")", "{", "// Terminate further request processing if preCall returns false.", "terminated", "=", "true", ";", "break", ";", "}", "}", "// Call httpresource method", "if", "(", "!", "terminated", ")", "{", "// Wrap responder to make post hook calls.", "responder", "=", "new", "WrappedHttpResponder", "(", "responder", ",", "handlerHooks", ",", "request", ",", "info", ")", ";", "if", "(", "httpResourceModel", ".", "handle", "(", "request", ",", "responder", ",", "matchedDestination", ".", "getGroupNameValues", "(", ")", ")", ".", "isStreaming", "(", ")", ")", "{", "responder", ".", "sendString", "(", "HttpResponseStatus", ".", "METHOD_NOT_ALLOWED", ",", "String", ".", "format", "(", "\"Body Consumer not supported for internalHttpResponder: %s\"", ",", "request", ".", "uri", "(", ")", ")", ")", ";", "}", "}", "}", "else", "if", "(", "routableDestinations", ".", "size", "(", ")", ">", "0", ")", "{", "//Found a matching resource but could not find the right HttpMethod so return 405", "responder", ".", "sendString", "(", "HttpResponseStatus", ".", "METHOD_NOT_ALLOWED", ",", "String", ".", "format", "(", "\"Problem accessing: %s. Reason: Method Not Allowed\"", ",", "request", ".", "uri", "(", ")", ")", ")", ";", "}", "else", "{", "responder", ".", "sendString", "(", "HttpResponseStatus", ".", "NOT_FOUND", ",", "String", ".", "format", "(", "\"Problem accessing: %s. Reason: Not Found\"", ",", "request", ".", "uri", "(", ")", ")", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "responder", ".", "sendString", "(", "HttpResponseStatus", ".", "INTERNAL_SERVER_ERROR", ",", "String", ".", "format", "(", "\"Caught exception processing request. Reason: %s\"", ",", "t", ".", "getMessage", "(", ")", ")", ")", ";", "LOG", ".", "error", "(", "\"Exception thrown during request processing for uri {}\"", ",", "request", ".", "uri", "(", ")", ",", "t", ")", ";", "}", "}" ]
Call the appropriate handler for handling the httprequest. 404 if path is not found. 405 if path is found but httpMethod does not match what's configured. @param request instance of {@code HttpRequest} @param responder instance of {@code HttpResponder} to handle the request.
[ "Call", "the", "appropriate", "handler", "for", "handling", "the", "httprequest", ".", "404", "if", "path", "is", "not", "found", ".", "405", "if", "path", "is", "found", "but", "httpMethod", "does", "not", "match", "what", "s", "configured", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceHandler.java#L163-L227
162,985
cdapio/netty-http
src/main/java/io/cdap/http/internal/HttpResourceHandler.java
HttpResourceHandler.getMatchedDestination
private PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel> getMatchedDestination(List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> routableDestinations, HttpMethod targetHttpMethod, String requestUri) { LOG.trace("Routable destinations for request {}: {}", requestUri, routableDestinations); Iterable<String> requestUriParts = splitAndOmitEmpty(requestUri, '/'); List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> matchedDestinations = new ArrayList<>(); long maxScore = 0; for (PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel> destination : routableDestinations) { HttpResourceModel resourceModel = destination.getDestination(); for (HttpMethod httpMethod : resourceModel.getHttpMethod()) { if (targetHttpMethod.equals(httpMethod)) { long score = getWeightedMatchScore(requestUriParts, splitAndOmitEmpty(resourceModel.getPath(), '/')); LOG.trace("Max score = {}. Weighted score for {} is {}. ", maxScore, destination, score); if (score > maxScore) { maxScore = score; matchedDestinations.clear(); matchedDestinations.add(destination); } else if (score == maxScore) { matchedDestinations.add(destination); } } } } if (matchedDestinations.size() > 1) { throw new IllegalStateException(String.format("Multiple matched handlers found for request uri %s: %s", requestUri, matchedDestinations)); } else if (matchedDestinations.size() == 1) { return matchedDestinations.get(0); } return null; }
java
private PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel> getMatchedDestination(List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> routableDestinations, HttpMethod targetHttpMethod, String requestUri) { LOG.trace("Routable destinations for request {}: {}", requestUri, routableDestinations); Iterable<String> requestUriParts = splitAndOmitEmpty(requestUri, '/'); List<PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel>> matchedDestinations = new ArrayList<>(); long maxScore = 0; for (PatternPathRouterWithGroups.RoutableDestination<HttpResourceModel> destination : routableDestinations) { HttpResourceModel resourceModel = destination.getDestination(); for (HttpMethod httpMethod : resourceModel.getHttpMethod()) { if (targetHttpMethod.equals(httpMethod)) { long score = getWeightedMatchScore(requestUriParts, splitAndOmitEmpty(resourceModel.getPath(), '/')); LOG.trace("Max score = {}. Weighted score for {} is {}. ", maxScore, destination, score); if (score > maxScore) { maxScore = score; matchedDestinations.clear(); matchedDestinations.add(destination); } else if (score == maxScore) { matchedDestinations.add(destination); } } } } if (matchedDestinations.size() > 1) { throw new IllegalStateException(String.format("Multiple matched handlers found for request uri %s: %s", requestUri, matchedDestinations)); } else if (matchedDestinations.size() == 1) { return matchedDestinations.get(0); } return null; }
[ "private", "PatternPathRouterWithGroups", ".", "RoutableDestination", "<", "HttpResourceModel", ">", "getMatchedDestination", "(", "List", "<", "PatternPathRouterWithGroups", ".", "RoutableDestination", "<", "HttpResourceModel", ">", ">", "routableDestinations", ",", "HttpMethod", "targetHttpMethod", ",", "String", "requestUri", ")", "{", "LOG", ".", "trace", "(", "\"Routable destinations for request {}: {}\"", ",", "requestUri", ",", "routableDestinations", ")", ";", "Iterable", "<", "String", ">", "requestUriParts", "=", "splitAndOmitEmpty", "(", "requestUri", ",", "'", "'", ")", ";", "List", "<", "PatternPathRouterWithGroups", ".", "RoutableDestination", "<", "HttpResourceModel", ">", ">", "matchedDestinations", "=", "new", "ArrayList", "<>", "(", ")", ";", "long", "maxScore", "=", "0", ";", "for", "(", "PatternPathRouterWithGroups", ".", "RoutableDestination", "<", "HttpResourceModel", ">", "destination", ":", "routableDestinations", ")", "{", "HttpResourceModel", "resourceModel", "=", "destination", ".", "getDestination", "(", ")", ";", "for", "(", "HttpMethod", "httpMethod", ":", "resourceModel", ".", "getHttpMethod", "(", ")", ")", "{", "if", "(", "targetHttpMethod", ".", "equals", "(", "httpMethod", ")", ")", "{", "long", "score", "=", "getWeightedMatchScore", "(", "requestUriParts", ",", "splitAndOmitEmpty", "(", "resourceModel", ".", "getPath", "(", ")", ",", "'", "'", ")", ")", ";", "LOG", ".", "trace", "(", "\"Max score = {}. Weighted score for {} is {}. \"", ",", "maxScore", ",", "destination", ",", "score", ")", ";", "if", "(", "score", ">", "maxScore", ")", "{", "maxScore", "=", "score", ";", "matchedDestinations", ".", "clear", "(", ")", ";", "matchedDestinations", ".", "add", "(", "destination", ")", ";", "}", "else", "if", "(", "score", "==", "maxScore", ")", "{", "matchedDestinations", ".", "add", "(", "destination", ")", ";", "}", "}", "}", "}", "if", "(", "matchedDestinations", ".", "size", "(", ")", ">", "1", ")", "{", "throw", "new", "IllegalStateException", "(", "String", ".", "format", "(", "\"Multiple matched handlers found for request uri %s: %s\"", ",", "requestUri", ",", "matchedDestinations", ")", ")", ";", "}", "else", "if", "(", "matchedDestinations", ".", "size", "(", ")", "==", "1", ")", "{", "return", "matchedDestinations", ".", "get", "(", "0", ")", ";", "}", "return", "null", ";", "}" ]
Get HttpResourceModel which matches the HttpMethod of the request. @param routableDestinations List of ResourceModels. @param targetHttpMethod HttpMethod. @param requestUri request URI. @return RoutableDestination that matches httpMethod that needs to be handled. null if there are no matches.
[ "Get", "HttpResourceModel", "which", "matches", "the", "HttpMethod", "of", "the", "request", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceHandler.java#L307-L341
162,986
cdapio/netty-http
src/main/java/io/cdap/http/internal/HttpResourceHandler.java
HttpResourceHandler.getWeightedMatchScore
private long getWeightedMatchScore(Iterable<String> requestUriParts, Iterable<String> destUriParts) { // The score calculated below is a base 5 number // The score will have one digit for one part of the URI // This will allow for 27 parts in the path since log (Long.MAX_VALUE) to base 5 = 27.13 // We limit the number of parts in the path to 25 using MAX_PATH_PARTS constant above to avoid overflow during // score calculation long score = 0; for (Iterator<String> rit = requestUriParts.iterator(), dit = destUriParts.iterator(); rit.hasNext() && dit.hasNext(); ) { String requestPart = rit.next(); String destPart = dit.next(); if (requestPart.equals(destPart)) { score = (score * 5) + 4; } else if (PatternPathRouterWithGroups.GROUP_PATTERN.matcher(destPart).matches()) { score = (score * 5) + 3; } else { score = (score * 5) + 2; } } return score; }
java
private long getWeightedMatchScore(Iterable<String> requestUriParts, Iterable<String> destUriParts) { // The score calculated below is a base 5 number // The score will have one digit for one part of the URI // This will allow for 27 parts in the path since log (Long.MAX_VALUE) to base 5 = 27.13 // We limit the number of parts in the path to 25 using MAX_PATH_PARTS constant above to avoid overflow during // score calculation long score = 0; for (Iterator<String> rit = requestUriParts.iterator(), dit = destUriParts.iterator(); rit.hasNext() && dit.hasNext(); ) { String requestPart = rit.next(); String destPart = dit.next(); if (requestPart.equals(destPart)) { score = (score * 5) + 4; } else if (PatternPathRouterWithGroups.GROUP_PATTERN.matcher(destPart).matches()) { score = (score * 5) + 3; } else { score = (score * 5) + 2; } } return score; }
[ "private", "long", "getWeightedMatchScore", "(", "Iterable", "<", "String", ">", "requestUriParts", ",", "Iterable", "<", "String", ">", "destUriParts", ")", "{", "// The score calculated below is a base 5 number", "// The score will have one digit for one part of the URI", "// This will allow for 27 parts in the path since log (Long.MAX_VALUE) to base 5 = 27.13", "// We limit the number of parts in the path to 25 using MAX_PATH_PARTS constant above to avoid overflow during", "// score calculation", "long", "score", "=", "0", ";", "for", "(", "Iterator", "<", "String", ">", "rit", "=", "requestUriParts", ".", "iterator", "(", ")", ",", "dit", "=", "destUriParts", ".", "iterator", "(", ")", ";", "rit", ".", "hasNext", "(", ")", "&&", "dit", ".", "hasNext", "(", ")", ";", ")", "{", "String", "requestPart", "=", "rit", ".", "next", "(", ")", ";", "String", "destPart", "=", "dit", ".", "next", "(", ")", ";", "if", "(", "requestPart", ".", "equals", "(", "destPart", ")", ")", "{", "score", "=", "(", "score", "*", "5", ")", "+", "4", ";", "}", "else", "if", "(", "PatternPathRouterWithGroups", ".", "GROUP_PATTERN", ".", "matcher", "(", "destPart", ")", ".", "matches", "(", ")", ")", "{", "score", "=", "(", "score", "*", "5", ")", "+", "3", ";", "}", "else", "{", "score", "=", "(", "score", "*", "5", ")", "+", "2", ";", "}", "}", "return", "score", ";", "}" ]
Generate a weighted score based on position for matches of URI parts. The matches are weighted in descending order from left to right. Exact match is weighted higher than group match, and group match is weighted higher than wildcard match. @param requestUriParts the parts of request URI @param destUriParts the parts of destination URI @return weighted score
[ "Generate", "a", "weighted", "score", "based", "on", "position", "for", "matches", "of", "URI", "parts", ".", "The", "matches", "are", "weighted", "in", "descending", "order", "from", "left", "to", "right", ".", "Exact", "match", "is", "weighted", "higher", "than", "group", "match", "and", "group", "match", "is", "weighted", "higher", "than", "wildcard", "match", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceHandler.java#L352-L372
162,987
cdapio/netty-http
src/main/java/io/cdap/http/internal/HttpResourceHandler.java
HttpResourceHandler.splitAndOmitEmpty
private static Iterable<String> splitAndOmitEmpty(final String str, final char splitChar) { return new Iterable<String>() { @Override public Iterator<String> iterator() { return new Iterator<String>() { int startIdx = 0; String next = null; @Override public boolean hasNext() { while (next == null && startIdx < str.length()) { int idx = str.indexOf(splitChar, startIdx); if (idx == startIdx) { // Omit empty string startIdx++; continue; } if (idx >= 0) { // Found the next part next = str.substring(startIdx, idx); startIdx = idx; } else { // The last part if (startIdx < str.length()) { next = str.substring(startIdx); startIdx = str.length(); } break; } } return next != null; } @Override public String next() { if (hasNext()) { String next = this.next; this.next = null; return next; } throw new NoSuchElementException("No more element"); } @Override public void remove() { throw new UnsupportedOperationException("Remove not supported"); } }; } }; }
java
private static Iterable<String> splitAndOmitEmpty(final String str, final char splitChar) { return new Iterable<String>() { @Override public Iterator<String> iterator() { return new Iterator<String>() { int startIdx = 0; String next = null; @Override public boolean hasNext() { while (next == null && startIdx < str.length()) { int idx = str.indexOf(splitChar, startIdx); if (idx == startIdx) { // Omit empty string startIdx++; continue; } if (idx >= 0) { // Found the next part next = str.substring(startIdx, idx); startIdx = idx; } else { // The last part if (startIdx < str.length()) { next = str.substring(startIdx); startIdx = str.length(); } break; } } return next != null; } @Override public String next() { if (hasNext()) { String next = this.next; this.next = null; return next; } throw new NoSuchElementException("No more element"); } @Override public void remove() { throw new UnsupportedOperationException("Remove not supported"); } }; } }; }
[ "private", "static", "Iterable", "<", "String", ">", "splitAndOmitEmpty", "(", "final", "String", "str", ",", "final", "char", "splitChar", ")", "{", "return", "new", "Iterable", "<", "String", ">", "(", ")", "{", "@", "Override", "public", "Iterator", "<", "String", ">", "iterator", "(", ")", "{", "return", "new", "Iterator", "<", "String", ">", "(", ")", "{", "int", "startIdx", "=", "0", ";", "String", "next", "=", "null", ";", "@", "Override", "public", "boolean", "hasNext", "(", ")", "{", "while", "(", "next", "==", "null", "&&", "startIdx", "<", "str", ".", "length", "(", ")", ")", "{", "int", "idx", "=", "str", ".", "indexOf", "(", "splitChar", ",", "startIdx", ")", ";", "if", "(", "idx", "==", "startIdx", ")", "{", "// Omit empty string", "startIdx", "++", ";", "continue", ";", "}", "if", "(", "idx", ">=", "0", ")", "{", "// Found the next part", "next", "=", "str", ".", "substring", "(", "startIdx", ",", "idx", ")", ";", "startIdx", "=", "idx", ";", "}", "else", "{", "// The last part", "if", "(", "startIdx", "<", "str", ".", "length", "(", ")", ")", "{", "next", "=", "str", ".", "substring", "(", "startIdx", ")", ";", "startIdx", "=", "str", ".", "length", "(", ")", ";", "}", "break", ";", "}", "}", "return", "next", "!=", "null", ";", "}", "@", "Override", "public", "String", "next", "(", ")", "{", "if", "(", "hasNext", "(", ")", ")", "{", "String", "next", "=", "this", ".", "next", ";", "this", ".", "next", "=", "null", ";", "return", "next", ";", "}", "throw", "new", "NoSuchElementException", "(", "\"No more element\"", ")", ";", "}", "@", "Override", "public", "void", "remove", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Remove not supported\"", ")", ";", "}", "}", ";", "}", "}", ";", "}" ]
Helper method to split a string by a given character, with empty parts omitted.
[ "Helper", "method", "to", "split", "a", "string", "by", "a", "given", "character", "with", "empty", "parts", "omitted", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpResourceHandler.java#L403-L454
162,988
cdapio/netty-http
src/main/java/io/cdap/http/internal/ParamConvertUtils.java
ParamConvertUtils.createPrimitiveTypeConverter
@Nullable private static Converter<List<String>, Object> createPrimitiveTypeConverter(final Class<?> resultClass) { Object defaultValue = defaultValue(resultClass); if (defaultValue == null) { // For primitive type, the default value shouldn't be null return null; } return new BasicConverter(defaultValue) { @Override protected Object convert(String value) throws Exception { return valueOf(value, resultClass); } }; }
java
@Nullable private static Converter<List<String>, Object> createPrimitiveTypeConverter(final Class<?> resultClass) { Object defaultValue = defaultValue(resultClass); if (defaultValue == null) { // For primitive type, the default value shouldn't be null return null; } return new BasicConverter(defaultValue) { @Override protected Object convert(String value) throws Exception { return valueOf(value, resultClass); } }; }
[ "@", "Nullable", "private", "static", "Converter", "<", "List", "<", "String", ">", ",", "Object", ">", "createPrimitiveTypeConverter", "(", "final", "Class", "<", "?", ">", "resultClass", ")", "{", "Object", "defaultValue", "=", "defaultValue", "(", "resultClass", ")", ";", "if", "(", "defaultValue", "==", "null", ")", "{", "// For primitive type, the default value shouldn't be null", "return", "null", ";", "}", "return", "new", "BasicConverter", "(", "defaultValue", ")", "{", "@", "Override", "protected", "Object", "convert", "(", "String", "value", ")", "throws", "Exception", "{", "return", "valueOf", "(", "value", ",", "resultClass", ")", ";", "}", "}", ";", "}" ]
Creates a converter function that converts value into primitive type. @return A converter function or {@code null} if the given type is not primitive type or boxed type
[ "Creates", "a", "converter", "function", "that", "converts", "value", "into", "primitive", "type", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/ParamConvertUtils.java#L158-L173
162,989
cdapio/netty-http
src/main/java/io/cdap/http/internal/ParamConvertUtils.java
ParamConvertUtils.createStringConstructorConverter
private static Converter<List<String>, Object> createStringConstructorConverter(Class<?> resultClass) { try { final Constructor<?> constructor = resultClass.getConstructor(String.class); return new BasicConverter(defaultValue(resultClass)) { @Override protected Object convert(String value) throws Exception { return constructor.newInstance(value); } }; } catch (Exception e) { return null; } }
java
private static Converter<List<String>, Object> createStringConstructorConverter(Class<?> resultClass) { try { final Constructor<?> constructor = resultClass.getConstructor(String.class); return new BasicConverter(defaultValue(resultClass)) { @Override protected Object convert(String value) throws Exception { return constructor.newInstance(value); } }; } catch (Exception e) { return null; } }
[ "private", "static", "Converter", "<", "List", "<", "String", ">", ",", "Object", ">", "createStringConstructorConverter", "(", "Class", "<", "?", ">", "resultClass", ")", "{", "try", "{", "final", "Constructor", "<", "?", ">", "constructor", "=", "resultClass", ".", "getConstructor", "(", "String", ".", "class", ")", ";", "return", "new", "BasicConverter", "(", "defaultValue", "(", "resultClass", ")", ")", "{", "@", "Override", "protected", "Object", "convert", "(", "String", "value", ")", "throws", "Exception", "{", "return", "constructor", ".", "newInstance", "(", "value", ")", ";", "}", "}", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "null", ";", "}", "}" ]
Creates a converter function that converts value using a constructor that accepts a single String argument. @return A converter function or {@code null} if the given type doesn't have a public constructor that accepts a single String argument.
[ "Creates", "a", "converter", "function", "that", "converts", "value", "using", "a", "constructor", "that", "accepts", "a", "single", "String", "argument", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/ParamConvertUtils.java#L182-L194
162,990
cdapio/netty-http
src/main/java/io/cdap/http/internal/ParamConvertUtils.java
ParamConvertUtils.valueOf
@Nullable private static Object valueOf(String value, Class<?> cls) { if (cls == Boolean.TYPE) { return Boolean.valueOf(value); } if (cls == Character.TYPE) { return value.length() >= 1 ? value.charAt(0) : defaultValue(char.class); } if (cls == Byte.TYPE) { return Byte.valueOf(value); } if (cls == Short.TYPE) { return Short.valueOf(value); } if (cls == Integer.TYPE) { return Integer.valueOf(value); } if (cls == Long.TYPE) { return Long.valueOf(value); } if (cls == Float.TYPE) { return Float.valueOf(value); } if (cls == Double.TYPE) { return Double.valueOf(value); } return null; }
java
@Nullable private static Object valueOf(String value, Class<?> cls) { if (cls == Boolean.TYPE) { return Boolean.valueOf(value); } if (cls == Character.TYPE) { return value.length() >= 1 ? value.charAt(0) : defaultValue(char.class); } if (cls == Byte.TYPE) { return Byte.valueOf(value); } if (cls == Short.TYPE) { return Short.valueOf(value); } if (cls == Integer.TYPE) { return Integer.valueOf(value); } if (cls == Long.TYPE) { return Long.valueOf(value); } if (cls == Float.TYPE) { return Float.valueOf(value); } if (cls == Double.TYPE) { return Double.valueOf(value); } return null; }
[ "@", "Nullable", "private", "static", "Object", "valueOf", "(", "String", "value", ",", "Class", "<", "?", ">", "cls", ")", "{", "if", "(", "cls", "==", "Boolean", ".", "TYPE", ")", "{", "return", "Boolean", ".", "valueOf", "(", "value", ")", ";", "}", "if", "(", "cls", "==", "Character", ".", "TYPE", ")", "{", "return", "value", ".", "length", "(", ")", ">=", "1", "?", "value", ".", "charAt", "(", "0", ")", ":", "defaultValue", "(", "char", ".", "class", ")", ";", "}", "if", "(", "cls", "==", "Byte", ".", "TYPE", ")", "{", "return", "Byte", ".", "valueOf", "(", "value", ")", ";", "}", "if", "(", "cls", "==", "Short", ".", "TYPE", ")", "{", "return", "Short", ".", "valueOf", "(", "value", ")", ";", "}", "if", "(", "cls", "==", "Integer", ".", "TYPE", ")", "{", "return", "Integer", ".", "valueOf", "(", "value", ")", ";", "}", "if", "(", "cls", "==", "Long", ".", "TYPE", ")", "{", "return", "Long", ".", "valueOf", "(", "value", ")", ";", "}", "if", "(", "cls", "==", "Float", ".", "TYPE", ")", "{", "return", "Float", ".", "valueOf", "(", "value", ")", ";", "}", "if", "(", "cls", "==", "Double", ".", "TYPE", ")", "{", "return", "Double", ".", "valueOf", "(", "value", ")", ";", "}", "return", "null", ";", "}" ]
Returns the value of the primitive type from the given string value. @param value the value to parse @param cls the primitive type class @return the boxed type value or {@code null} if the given class is not a primitive type
[ "Returns", "the", "value", "of", "the", "primitive", "type", "from", "the", "given", "string", "value", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/ParamConvertUtils.java#L314-L341
162,991
cdapio/netty-http
src/main/java/io/cdap/http/internal/ParamConvertUtils.java
ParamConvertUtils.getRawClass
private static Class<?> getRawClass(Type type) { if (type instanceof Class) { return (Class<?>) type; } if (type instanceof ParameterizedType) { return getRawClass(((ParameterizedType) type).getRawType()); } // For TypeVariable and WildcardType, returns the first upper bound. if (type instanceof TypeVariable) { return getRawClass(((TypeVariable) type).getBounds()[0]); } if (type instanceof WildcardType) { return getRawClass(((WildcardType) type).getUpperBounds()[0]); } if (type instanceof GenericArrayType) { Class<?> componentClass = getRawClass(((GenericArrayType) type).getGenericComponentType()); return Array.newInstance(componentClass, 0).getClass(); } // This shouldn't happen as we captured all implementations of Type above (as or Java 8) throw new IllegalArgumentException("Unsupported type " + type + " of type class " + type.getClass()); }
java
private static Class<?> getRawClass(Type type) { if (type instanceof Class) { return (Class<?>) type; } if (type instanceof ParameterizedType) { return getRawClass(((ParameterizedType) type).getRawType()); } // For TypeVariable and WildcardType, returns the first upper bound. if (type instanceof TypeVariable) { return getRawClass(((TypeVariable) type).getBounds()[0]); } if (type instanceof WildcardType) { return getRawClass(((WildcardType) type).getUpperBounds()[0]); } if (type instanceof GenericArrayType) { Class<?> componentClass = getRawClass(((GenericArrayType) type).getGenericComponentType()); return Array.newInstance(componentClass, 0).getClass(); } // This shouldn't happen as we captured all implementations of Type above (as or Java 8) throw new IllegalArgumentException("Unsupported type " + type + " of type class " + type.getClass()); }
[ "private", "static", "Class", "<", "?", ">", "getRawClass", "(", "Type", "type", ")", "{", "if", "(", "type", "instanceof", "Class", ")", "{", "return", "(", "Class", "<", "?", ">", ")", "type", ";", "}", "if", "(", "type", "instanceof", "ParameterizedType", ")", "{", "return", "getRawClass", "(", "(", "(", "ParameterizedType", ")", "type", ")", ".", "getRawType", "(", ")", ")", ";", "}", "// For TypeVariable and WildcardType, returns the first upper bound.", "if", "(", "type", "instanceof", "TypeVariable", ")", "{", "return", "getRawClass", "(", "(", "(", "TypeVariable", ")", "type", ")", ".", "getBounds", "(", ")", "[", "0", "]", ")", ";", "}", "if", "(", "type", "instanceof", "WildcardType", ")", "{", "return", "getRawClass", "(", "(", "(", "WildcardType", ")", "type", ")", ".", "getUpperBounds", "(", ")", "[", "0", "]", ")", ";", "}", "if", "(", "type", "instanceof", "GenericArrayType", ")", "{", "Class", "<", "?", ">", "componentClass", "=", "getRawClass", "(", "(", "(", "GenericArrayType", ")", "type", ")", ".", "getGenericComponentType", "(", ")", ")", ";", "return", "Array", ".", "newInstance", "(", "componentClass", ",", "0", ")", ".", "getClass", "(", ")", ";", "}", "// This shouldn't happen as we captured all implementations of Type above (as or Java 8)", "throw", "new", "IllegalArgumentException", "(", "\"Unsupported type \"", "+", "type", "+", "\" of type class \"", "+", "type", ".", "getClass", "(", ")", ")", ";", "}" ]
Returns the raw class of the given type.
[ "Returns", "the", "raw", "class", "of", "the", "given", "type", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/ParamConvertUtils.java#L346-L366
162,992
cdapio/netty-http
src/main/java/io/cdap/http/internal/HttpMethodInfo.java
HttpMethodInfo.invoke
void invoke(HttpRequest request) throws Exception { bodyConsumer = null; Object invokeResult; try { args[0] = this.request = request; invokeResult = method.invoke(handler, args); } catch (InvocationTargetException e) { exceptionHandler.handle(e.getTargetException(), request, responder); return; } catch (Throwable t) { exceptionHandler.handle(t, request, responder); return; } if (isStreaming) { // Casting guarantee to be succeeded. bodyConsumer = (BodyConsumer) invokeResult; } }
java
void invoke(HttpRequest request) throws Exception { bodyConsumer = null; Object invokeResult; try { args[0] = this.request = request; invokeResult = method.invoke(handler, args); } catch (InvocationTargetException e) { exceptionHandler.handle(e.getTargetException(), request, responder); return; } catch (Throwable t) { exceptionHandler.handle(t, request, responder); return; } if (isStreaming) { // Casting guarantee to be succeeded. bodyConsumer = (BodyConsumer) invokeResult; } }
[ "void", "invoke", "(", "HttpRequest", "request", ")", "throws", "Exception", "{", "bodyConsumer", "=", "null", ";", "Object", "invokeResult", ";", "try", "{", "args", "[", "0", "]", "=", "this", ".", "request", "=", "request", ";", "invokeResult", "=", "method", ".", "invoke", "(", "handler", ",", "args", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "exceptionHandler", ".", "handle", "(", "e", ".", "getTargetException", "(", ")", ",", "request", ",", "responder", ")", ";", "return", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "exceptionHandler", ".", "handle", "(", "t", ",", "request", ",", "responder", ")", ";", "return", ";", "}", "if", "(", "isStreaming", ")", "{", "// Casting guarantee to be succeeded.", "bodyConsumer", "=", "(", "BodyConsumer", ")", "invokeResult", ";", "}", "}" ]
Calls the httpHandler method.
[ "Calls", "the", "httpHandler", "method", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpMethodInfo.java#L77-L95
162,993
cdapio/netty-http
src/main/java/io/cdap/http/internal/HttpMethodInfo.java
HttpMethodInfo.sendError
void sendError(HttpResponseStatus status, Throwable ex) { String msg; if (ex instanceof InvocationTargetException) { msg = String.format("Exception Encountered while processing request : %s", ex.getCause().getMessage()); } else { msg = String.format("Exception Encountered while processing request: %s", ex.getMessage()); } // Send the status and message, followed by closing of the connection. responder.sendString(status, msg, new DefaultHttpHeaders().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE)); if (bodyConsumer != null) { bodyConsumerError(ex); } }
java
void sendError(HttpResponseStatus status, Throwable ex) { String msg; if (ex instanceof InvocationTargetException) { msg = String.format("Exception Encountered while processing request : %s", ex.getCause().getMessage()); } else { msg = String.format("Exception Encountered while processing request: %s", ex.getMessage()); } // Send the status and message, followed by closing of the connection. responder.sendString(status, msg, new DefaultHttpHeaders().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE)); if (bodyConsumer != null) { bodyConsumerError(ex); } }
[ "void", "sendError", "(", "HttpResponseStatus", "status", ",", "Throwable", "ex", ")", "{", "String", "msg", ";", "if", "(", "ex", "instanceof", "InvocationTargetException", ")", "{", "msg", "=", "String", ".", "format", "(", "\"Exception Encountered while processing request : %s\"", ",", "ex", ".", "getCause", "(", ")", ".", "getMessage", "(", ")", ")", ";", "}", "else", "{", "msg", "=", "String", ".", "format", "(", "\"Exception Encountered while processing request: %s\"", ",", "ex", ".", "getMessage", "(", ")", ")", ";", "}", "// Send the status and message, followed by closing of the connection.", "responder", ".", "sendString", "(", "status", ",", "msg", ",", "new", "DefaultHttpHeaders", "(", ")", ".", "set", "(", "HttpHeaderNames", ".", "CONNECTION", ",", "HttpHeaderValues", ".", "CLOSE", ")", ")", ";", "if", "(", "bodyConsumer", "!=", "null", ")", "{", "bodyConsumerError", "(", "ex", ")", ";", "}", "}" ]
Sends the error to responder.
[ "Sends", "the", "error", "to", "responder", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/HttpMethodInfo.java#L170-L184
162,994
cdapio/netty-http
src/main/java/io/cdap/http/internal/PatternPathRouterWithGroups.java
PatternPathRouterWithGroups.add
public void add(final String source, final T destination) { // replace multiple slashes with a single slash. String path = source.replaceAll("/+", "/"); path = (path.endsWith("/") && path.length() > 1) ? path.substring(0, path.length() - 1) : path; String[] parts = path.split("/", maxPathParts + 2); if (parts.length - 1 > maxPathParts) { throw new IllegalArgumentException(String.format("Number of parts of path %s exceeds allowed limit %s", source, maxPathParts)); } StringBuilder sb = new StringBuilder(); List<String> groupNames = new ArrayList<>(); for (String part : parts) { Matcher groupMatcher = GROUP_PATTERN.matcher(part); if (groupMatcher.matches()) { groupNames.add(groupMatcher.group(1)); sb.append("([^/]+?)"); } else if (WILD_CARD_PATTERN.matcher(part).matches()) { sb.append(".*?"); } else { sb.append(part); } sb.append("/"); } //Ignore the last "/" sb.setLength(sb.length() - 1); Pattern pattern = Pattern.compile(sb.toString()); patternRouteList.add(ImmutablePair.of(pattern, new RouteDestinationWithGroups(destination, groupNames))); }
java
public void add(final String source, final T destination) { // replace multiple slashes with a single slash. String path = source.replaceAll("/+", "/"); path = (path.endsWith("/") && path.length() > 1) ? path.substring(0, path.length() - 1) : path; String[] parts = path.split("/", maxPathParts + 2); if (parts.length - 1 > maxPathParts) { throw new IllegalArgumentException(String.format("Number of parts of path %s exceeds allowed limit %s", source, maxPathParts)); } StringBuilder sb = new StringBuilder(); List<String> groupNames = new ArrayList<>(); for (String part : parts) { Matcher groupMatcher = GROUP_PATTERN.matcher(part); if (groupMatcher.matches()) { groupNames.add(groupMatcher.group(1)); sb.append("([^/]+?)"); } else if (WILD_CARD_PATTERN.matcher(part).matches()) { sb.append(".*?"); } else { sb.append(part); } sb.append("/"); } //Ignore the last "/" sb.setLength(sb.length() - 1); Pattern pattern = Pattern.compile(sb.toString()); patternRouteList.add(ImmutablePair.of(pattern, new RouteDestinationWithGroups(destination, groupNames))); }
[ "public", "void", "add", "(", "final", "String", "source", ",", "final", "T", "destination", ")", "{", "// replace multiple slashes with a single slash.", "String", "path", "=", "source", ".", "replaceAll", "(", "\"/+\"", ",", "\"/\"", ")", ";", "path", "=", "(", "path", ".", "endsWith", "(", "\"/\"", ")", "&&", "path", ".", "length", "(", ")", ">", "1", ")", "?", "path", ".", "substring", "(", "0", ",", "path", ".", "length", "(", ")", "-", "1", ")", ":", "path", ";", "String", "[", "]", "parts", "=", "path", ".", "split", "(", "\"/\"", ",", "maxPathParts", "+", "2", ")", ";", "if", "(", "parts", ".", "length", "-", "1", ">", "maxPathParts", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"Number of parts of path %s exceeds allowed limit %s\"", ",", "source", ",", "maxPathParts", ")", ")", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "List", "<", "String", ">", "groupNames", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "part", ":", "parts", ")", "{", "Matcher", "groupMatcher", "=", "GROUP_PATTERN", ".", "matcher", "(", "part", ")", ";", "if", "(", "groupMatcher", ".", "matches", "(", ")", ")", "{", "groupNames", ".", "add", "(", "groupMatcher", ".", "group", "(", "1", ")", ")", ";", "sb", ".", "append", "(", "\"([^/]+?)\"", ")", ";", "}", "else", "if", "(", "WILD_CARD_PATTERN", ".", "matcher", "(", "part", ")", ".", "matches", "(", ")", ")", "{", "sb", ".", "append", "(", "\".*?\"", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "part", ")", ";", "}", "sb", ".", "append", "(", "\"/\"", ")", ";", "}", "//Ignore the last \"/\"", "sb", ".", "setLength", "(", "sb", ".", "length", "(", ")", "-", "1", ")", ";", "Pattern", "pattern", "=", "Pattern", ".", "compile", "(", "sb", ".", "toString", "(", ")", ")", ";", "patternRouteList", ".", "add", "(", "ImmutablePair", ".", "of", "(", "pattern", ",", "new", "RouteDestinationWithGroups", "(", "destination", ",", "groupNames", ")", ")", ")", ";", "}" ]
Add a source and destination. @param source Source path to be routed. Routed path can have named wild-card pattern with braces "{}". @param destination Destination of the path.
[ "Add", "a", "source", "and", "destination", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/PatternPathRouterWithGroups.java#L62-L97
162,995
cdapio/netty-http
src/main/java/io/cdap/http/internal/PatternPathRouterWithGroups.java
PatternPathRouterWithGroups.getDestinations
public List<RoutableDestination<T>> getDestinations(String path) { String cleanPath = (path.endsWith("/") && path.length() > 1) ? path.substring(0, path.length() - 1) : path; List<RoutableDestination<T>> result = new ArrayList<>(); for (ImmutablePair<Pattern, RouteDestinationWithGroups> patternRoute : patternRouteList) { Map<String, String> groupNameValuesBuilder = new HashMap<>(); Matcher matcher = patternRoute.getFirst().matcher(cleanPath); if (matcher.matches()) { int matchIndex = 1; for (String name : patternRoute.getSecond().getGroupNames()) { String value = matcher.group(matchIndex); groupNameValuesBuilder.put(name, value); matchIndex++; } result.add(new RoutableDestination<>(patternRoute.getSecond().getDestination(), groupNameValuesBuilder)); } } return result; }
java
public List<RoutableDestination<T>> getDestinations(String path) { String cleanPath = (path.endsWith("/") && path.length() > 1) ? path.substring(0, path.length() - 1) : path; List<RoutableDestination<T>> result = new ArrayList<>(); for (ImmutablePair<Pattern, RouteDestinationWithGroups> patternRoute : patternRouteList) { Map<String, String> groupNameValuesBuilder = new HashMap<>(); Matcher matcher = patternRoute.getFirst().matcher(cleanPath); if (matcher.matches()) { int matchIndex = 1; for (String name : patternRoute.getSecond().getGroupNames()) { String value = matcher.group(matchIndex); groupNameValuesBuilder.put(name, value); matchIndex++; } result.add(new RoutableDestination<>(patternRoute.getSecond().getDestination(), groupNameValuesBuilder)); } } return result; }
[ "public", "List", "<", "RoutableDestination", "<", "T", ">", ">", "getDestinations", "(", "String", "path", ")", "{", "String", "cleanPath", "=", "(", "path", ".", "endsWith", "(", "\"/\"", ")", "&&", "path", ".", "length", "(", ")", ">", "1", ")", "?", "path", ".", "substring", "(", "0", ",", "path", ".", "length", "(", ")", "-", "1", ")", ":", "path", ";", "List", "<", "RoutableDestination", "<", "T", ">", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "ImmutablePair", "<", "Pattern", ",", "RouteDestinationWithGroups", ">", "patternRoute", ":", "patternRouteList", ")", "{", "Map", "<", "String", ",", "String", ">", "groupNameValuesBuilder", "=", "new", "HashMap", "<>", "(", ")", ";", "Matcher", "matcher", "=", "patternRoute", ".", "getFirst", "(", ")", ".", "matcher", "(", "cleanPath", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "int", "matchIndex", "=", "1", ";", "for", "(", "String", "name", ":", "patternRoute", ".", "getSecond", "(", ")", ".", "getGroupNames", "(", ")", ")", "{", "String", "value", "=", "matcher", ".", "group", "(", "matchIndex", ")", ";", "groupNameValuesBuilder", ".", "put", "(", "name", ",", "value", ")", ";", "matchIndex", "++", ";", "}", "result", ".", "add", "(", "new", "RoutableDestination", "<>", "(", "patternRoute", ".", "getSecond", "(", ")", ".", "getDestination", "(", ")", ",", "groupNameValuesBuilder", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Get a list of destinations and the values matching templated parameter for the given path. Returns an empty list when there are no destinations that are matched. @param path path to be routed. @return List of Destinations matching the given route.
[ "Get", "a", "list", "of", "destinations", "and", "the", "values", "matching", "templated", "parameter", "for", "the", "given", "path", ".", "Returns", "an", "empty", "list", "when", "there", "are", "no", "destinations", "that", "are", "matched", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/PatternPathRouterWithGroups.java#L106-L127
162,996
cdapio/netty-http
src/main/java/io/cdap/http/NettyHttpService.java
NettyHttpService.start
public synchronized void start() throws Exception { if (state == State.RUNNING) { LOG.debug("Ignore start() call on HTTP service {} since it has already been started.", serviceName); return; } if (state != State.NOT_STARTED) { if (state == State.STOPPED) { throw new IllegalStateException("Cannot start the HTTP service " + serviceName + " again since it has been stopped"); } throw new IllegalStateException("Cannot start the HTTP service " + serviceName + " because it was failed earlier"); } try { LOG.info("Starting HTTP Service {} at address {}", serviceName, bindAddress); channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE); resourceHandler.init(handlerContext); eventExecutorGroup = createEventExecutorGroup(execThreadPoolSize); bootstrap = createBootstrap(channelGroup); Channel serverChannel = bootstrap.bind(bindAddress).sync().channel(); channelGroup.add(serverChannel); bindAddress = (InetSocketAddress) serverChannel.localAddress(); LOG.debug("Started HTTP Service {} at address {}", serviceName, bindAddress); state = State.RUNNING; } catch (Throwable t) { // Release resources if there is any failure channelGroup.close().awaitUninterruptibly(); try { if (bootstrap != null) { shutdownExecutorGroups(0, 5, TimeUnit.SECONDS, bootstrap.config().group(), bootstrap.config().childGroup(), eventExecutorGroup); } else { shutdownExecutorGroups(0, 5, TimeUnit.SECONDS, eventExecutorGroup); } } catch (Throwable t2) { t.addSuppressed(t2); } state = State.FAILED; throw t; } }
java
public synchronized void start() throws Exception { if (state == State.RUNNING) { LOG.debug("Ignore start() call on HTTP service {} since it has already been started.", serviceName); return; } if (state != State.NOT_STARTED) { if (state == State.STOPPED) { throw new IllegalStateException("Cannot start the HTTP service " + serviceName + " again since it has been stopped"); } throw new IllegalStateException("Cannot start the HTTP service " + serviceName + " because it was failed earlier"); } try { LOG.info("Starting HTTP Service {} at address {}", serviceName, bindAddress); channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE); resourceHandler.init(handlerContext); eventExecutorGroup = createEventExecutorGroup(execThreadPoolSize); bootstrap = createBootstrap(channelGroup); Channel serverChannel = bootstrap.bind(bindAddress).sync().channel(); channelGroup.add(serverChannel); bindAddress = (InetSocketAddress) serverChannel.localAddress(); LOG.debug("Started HTTP Service {} at address {}", serviceName, bindAddress); state = State.RUNNING; } catch (Throwable t) { // Release resources if there is any failure channelGroup.close().awaitUninterruptibly(); try { if (bootstrap != null) { shutdownExecutorGroups(0, 5, TimeUnit.SECONDS, bootstrap.config().group(), bootstrap.config().childGroup(), eventExecutorGroup); } else { shutdownExecutorGroups(0, 5, TimeUnit.SECONDS, eventExecutorGroup); } } catch (Throwable t2) { t.addSuppressed(t2); } state = State.FAILED; throw t; } }
[ "public", "synchronized", "void", "start", "(", ")", "throws", "Exception", "{", "if", "(", "state", "==", "State", ".", "RUNNING", ")", "{", "LOG", ".", "debug", "(", "\"Ignore start() call on HTTP service {} since it has already been started.\"", ",", "serviceName", ")", ";", "return", ";", "}", "if", "(", "state", "!=", "State", ".", "NOT_STARTED", ")", "{", "if", "(", "state", "==", "State", ".", "STOPPED", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Cannot start the HTTP service \"", "+", "serviceName", "+", "\" again since it has been stopped\"", ")", ";", "}", "throw", "new", "IllegalStateException", "(", "\"Cannot start the HTTP service \"", "+", "serviceName", "+", "\" because it was failed earlier\"", ")", ";", "}", "try", "{", "LOG", ".", "info", "(", "\"Starting HTTP Service {} at address {}\"", ",", "serviceName", ",", "bindAddress", ")", ";", "channelGroup", "=", "new", "DefaultChannelGroup", "(", "ImmediateEventExecutor", ".", "INSTANCE", ")", ";", "resourceHandler", ".", "init", "(", "handlerContext", ")", ";", "eventExecutorGroup", "=", "createEventExecutorGroup", "(", "execThreadPoolSize", ")", ";", "bootstrap", "=", "createBootstrap", "(", "channelGroup", ")", ";", "Channel", "serverChannel", "=", "bootstrap", ".", "bind", "(", "bindAddress", ")", ".", "sync", "(", ")", ".", "channel", "(", ")", ";", "channelGroup", ".", "add", "(", "serverChannel", ")", ";", "bindAddress", "=", "(", "InetSocketAddress", ")", "serverChannel", ".", "localAddress", "(", ")", ";", "LOG", ".", "debug", "(", "\"Started HTTP Service {} at address {}\"", ",", "serviceName", ",", "bindAddress", ")", ";", "state", "=", "State", ".", "RUNNING", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "// Release resources if there is any failure", "channelGroup", ".", "close", "(", ")", ".", "awaitUninterruptibly", "(", ")", ";", "try", "{", "if", "(", "bootstrap", "!=", "null", ")", "{", "shutdownExecutorGroups", "(", "0", ",", "5", ",", "TimeUnit", ".", "SECONDS", ",", "bootstrap", ".", "config", "(", ")", ".", "group", "(", ")", ",", "bootstrap", ".", "config", "(", ")", ".", "childGroup", "(", ")", ",", "eventExecutorGroup", ")", ";", "}", "else", "{", "shutdownExecutorGroups", "(", "0", ",", "5", ",", "TimeUnit", ".", "SECONDS", ",", "eventExecutorGroup", ")", ";", "}", "}", "catch", "(", "Throwable", "t2", ")", "{", "t", ".", "addSuppressed", "(", "t2", ")", ";", "}", "state", "=", "State", ".", "FAILED", ";", "throw", "t", ";", "}", "}" ]
Starts the HTTP service. @throws Exception if the service failed to started
[ "Starts", "the", "HTTP", "service", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/NettyHttpService.java#L158-L201
162,997
cdapio/netty-http
src/main/java/io/cdap/http/NettyHttpService.java
NettyHttpService.stop
public synchronized void stop(long quietPeriod, long timeout, TimeUnit unit) throws Exception { if (state == State.STOPPED) { LOG.debug("Ignore stop() call on HTTP service {} since it has already been stopped.", serviceName); return; } LOG.info("Stopping HTTP Service {}", serviceName); try { try { channelGroup.close().awaitUninterruptibly(); } finally { try { shutdownExecutorGroups(quietPeriod, timeout, unit, bootstrap.config().group(), bootstrap.config().childGroup(), eventExecutorGroup); } finally { resourceHandler.destroy(handlerContext); } } } catch (Throwable t) { state = State.FAILED; throw t; } state = State.STOPPED; LOG.debug("Stopped HTTP Service {} on address {}", serviceName, bindAddress); }
java
public synchronized void stop(long quietPeriod, long timeout, TimeUnit unit) throws Exception { if (state == State.STOPPED) { LOG.debug("Ignore stop() call on HTTP service {} since it has already been stopped.", serviceName); return; } LOG.info("Stopping HTTP Service {}", serviceName); try { try { channelGroup.close().awaitUninterruptibly(); } finally { try { shutdownExecutorGroups(quietPeriod, timeout, unit, bootstrap.config().group(), bootstrap.config().childGroup(), eventExecutorGroup); } finally { resourceHandler.destroy(handlerContext); } } } catch (Throwable t) { state = State.FAILED; throw t; } state = State.STOPPED; LOG.debug("Stopped HTTP Service {} on address {}", serviceName, bindAddress); }
[ "public", "synchronized", "void", "stop", "(", "long", "quietPeriod", ",", "long", "timeout", ",", "TimeUnit", "unit", ")", "throws", "Exception", "{", "if", "(", "state", "==", "State", ".", "STOPPED", ")", "{", "LOG", ".", "debug", "(", "\"Ignore stop() call on HTTP service {} since it has already been stopped.\"", ",", "serviceName", ")", ";", "return", ";", "}", "LOG", ".", "info", "(", "\"Stopping HTTP Service {}\"", ",", "serviceName", ")", ";", "try", "{", "try", "{", "channelGroup", ".", "close", "(", ")", ".", "awaitUninterruptibly", "(", ")", ";", "}", "finally", "{", "try", "{", "shutdownExecutorGroups", "(", "quietPeriod", ",", "timeout", ",", "unit", ",", "bootstrap", ".", "config", "(", ")", ".", "group", "(", ")", ",", "bootstrap", ".", "config", "(", ")", ".", "childGroup", "(", ")", ",", "eventExecutorGroup", ")", ";", "}", "finally", "{", "resourceHandler", ".", "destroy", "(", "handlerContext", ")", ";", "}", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "state", "=", "State", ".", "FAILED", ";", "throw", "t", ";", "}", "state", "=", "State", ".", "STOPPED", ";", "LOG", ".", "debug", "(", "\"Stopped HTTP Service {} on address {}\"", ",", "serviceName", ",", "bindAddress", ")", ";", "}" ]
Stops the HTTP service gracefully and release all resources. @param quietPeriod the quiet period as described in the documentation of {@link EventExecutorGroup} @param timeout the maximum amount of time to wait until the executor is {@linkplain EventExecutorGroup#shutdown()} regardless if a task was submitted during the quiet period @param unit the unit of {@code quietPeriod} and {@code timeout} @throws Exception if there is exception raised during shutdown.
[ "Stops", "the", "HTTP", "service", "gracefully", "and", "release", "all", "resources", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/NettyHttpService.java#L237-L262
162,998
cdapio/netty-http
src/main/java/io/cdap/http/NettyHttpService.java
NettyHttpService.createBootstrap
private ServerBootstrap createBootstrap(final ChannelGroup channelGroup) throws Exception { EventLoopGroup bossGroup = new NioEventLoopGroup(bossThreadPoolSize, createDaemonThreadFactory(serviceName + "-boss-thread-%d")); EventLoopGroup workerGroup = new NioEventLoopGroup(workerThreadPoolSize, createDaemonThreadFactory(serviceName + "-worker-thread-%d")); ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap .group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) .childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { channelGroup.add(ch); ChannelPipeline pipeline = ch.pipeline(); if (sslHandlerFactory != null) { // Add SSLHandler if SSL is enabled pipeline.addLast("ssl", sslHandlerFactory.create(ch.alloc())); } pipeline.addLast("codec", new HttpServerCodec()); pipeline.addLast("compressor", new HttpContentCompressor()); pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); pipeline.addLast("keepAlive", new HttpServerKeepAliveHandler()); pipeline.addLast("router", new RequestRouter(resourceHandler, httpChunkLimit, sslHandlerFactory != null)); if (eventExecutorGroup == null) { pipeline.addLast("dispatcher", new HttpDispatcher()); } else { pipeline.addLast(eventExecutorGroup, "dispatcher", new HttpDispatcher()); } if (pipelineModifier != null) { pipelineModifier.modify(pipeline); } } }); for (Map.Entry<ChannelOption, Object> entry : channelConfigs.entrySet()) { bootstrap.option(entry.getKey(), entry.getValue()); } for (Map.Entry<ChannelOption, Object> entry : childChannelConfigs.entrySet()) { bootstrap.childOption(entry.getKey(), entry.getValue()); } return bootstrap; }
java
private ServerBootstrap createBootstrap(final ChannelGroup channelGroup) throws Exception { EventLoopGroup bossGroup = new NioEventLoopGroup(bossThreadPoolSize, createDaemonThreadFactory(serviceName + "-boss-thread-%d")); EventLoopGroup workerGroup = new NioEventLoopGroup(workerThreadPoolSize, createDaemonThreadFactory(serviceName + "-worker-thread-%d")); ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap .group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) .childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { channelGroup.add(ch); ChannelPipeline pipeline = ch.pipeline(); if (sslHandlerFactory != null) { // Add SSLHandler if SSL is enabled pipeline.addLast("ssl", sslHandlerFactory.create(ch.alloc())); } pipeline.addLast("codec", new HttpServerCodec()); pipeline.addLast("compressor", new HttpContentCompressor()); pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); pipeline.addLast("keepAlive", new HttpServerKeepAliveHandler()); pipeline.addLast("router", new RequestRouter(resourceHandler, httpChunkLimit, sslHandlerFactory != null)); if (eventExecutorGroup == null) { pipeline.addLast("dispatcher", new HttpDispatcher()); } else { pipeline.addLast(eventExecutorGroup, "dispatcher", new HttpDispatcher()); } if (pipelineModifier != null) { pipelineModifier.modify(pipeline); } } }); for (Map.Entry<ChannelOption, Object> entry : channelConfigs.entrySet()) { bootstrap.option(entry.getKey(), entry.getValue()); } for (Map.Entry<ChannelOption, Object> entry : childChannelConfigs.entrySet()) { bootstrap.childOption(entry.getKey(), entry.getValue()); } return bootstrap; }
[ "private", "ServerBootstrap", "createBootstrap", "(", "final", "ChannelGroup", "channelGroup", ")", "throws", "Exception", "{", "EventLoopGroup", "bossGroup", "=", "new", "NioEventLoopGroup", "(", "bossThreadPoolSize", ",", "createDaemonThreadFactory", "(", "serviceName", "+", "\"-boss-thread-%d\"", ")", ")", ";", "EventLoopGroup", "workerGroup", "=", "new", "NioEventLoopGroup", "(", "workerThreadPoolSize", ",", "createDaemonThreadFactory", "(", "serviceName", "+", "\"-worker-thread-%d\"", ")", ")", ";", "ServerBootstrap", "bootstrap", "=", "new", "ServerBootstrap", "(", ")", ";", "bootstrap", ".", "group", "(", "bossGroup", ",", "workerGroup", ")", ".", "channel", "(", "NioServerSocketChannel", ".", "class", ")", ".", "childHandler", "(", "new", "ChannelInitializer", "<", "SocketChannel", ">", "(", ")", "{", "@", "Override", "protected", "void", "initChannel", "(", "SocketChannel", "ch", ")", "throws", "Exception", "{", "channelGroup", ".", "add", "(", "ch", ")", ";", "ChannelPipeline", "pipeline", "=", "ch", ".", "pipeline", "(", ")", ";", "if", "(", "sslHandlerFactory", "!=", "null", ")", "{", "// Add SSLHandler if SSL is enabled", "pipeline", ".", "addLast", "(", "\"ssl\"", ",", "sslHandlerFactory", ".", "create", "(", "ch", ".", "alloc", "(", ")", ")", ")", ";", "}", "pipeline", ".", "addLast", "(", "\"codec\"", ",", "new", "HttpServerCodec", "(", ")", ")", ";", "pipeline", ".", "addLast", "(", "\"compressor\"", ",", "new", "HttpContentCompressor", "(", ")", ")", ";", "pipeline", ".", "addLast", "(", "\"chunkedWriter\"", ",", "new", "ChunkedWriteHandler", "(", ")", ")", ";", "pipeline", ".", "addLast", "(", "\"keepAlive\"", ",", "new", "HttpServerKeepAliveHandler", "(", ")", ")", ";", "pipeline", ".", "addLast", "(", "\"router\"", ",", "new", "RequestRouter", "(", "resourceHandler", ",", "httpChunkLimit", ",", "sslHandlerFactory", "!=", "null", ")", ")", ";", "if", "(", "eventExecutorGroup", "==", "null", ")", "{", "pipeline", ".", "addLast", "(", "\"dispatcher\"", ",", "new", "HttpDispatcher", "(", ")", ")", ";", "}", "else", "{", "pipeline", ".", "addLast", "(", "eventExecutorGroup", ",", "\"dispatcher\"", ",", "new", "HttpDispatcher", "(", ")", ")", ";", "}", "if", "(", "pipelineModifier", "!=", "null", ")", "{", "pipelineModifier", ".", "modify", "(", "pipeline", ")", ";", "}", "}", "}", ")", ";", "for", "(", "Map", ".", "Entry", "<", "ChannelOption", ",", "Object", ">", "entry", ":", "channelConfigs", ".", "entrySet", "(", ")", ")", "{", "bootstrap", ".", "option", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "for", "(", "Map", ".", "Entry", "<", "ChannelOption", ",", "Object", ">", "entry", ":", "childChannelConfigs", ".", "entrySet", "(", ")", ")", "{", "bootstrap", ".", "childOption", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "return", "bootstrap", ";", "}" ]
Creates the server bootstrap.
[ "Creates", "the", "server", "bootstrap", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/NettyHttpService.java#L322-L366
162,999
cdapio/netty-http
src/main/java/io/cdap/http/internal/RequestRouter.java
RequestRouter.channelRead
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { if (exceptionRaised.get()) { return; } if (!(msg instanceof HttpRequest)) { // If there is no methodInfo, it means the request was already rejected. // What we received here is just residue of the request, which can be ignored. if (methodInfo != null) { ReferenceCountUtil.retain(msg); ctx.fireChannelRead(msg); } return; } HttpRequest request = (HttpRequest) msg; BasicHttpResponder responder = new BasicHttpResponder(ctx.channel(), sslEnabled); // Reset the methodInfo for the incoming request error handling methodInfo = null; methodInfo = prepareHandleMethod(request, responder, ctx); if (methodInfo != null) { ReferenceCountUtil.retain(msg); ctx.fireChannelRead(msg); } else { if (!responder.isResponded()) { // If not yet responded, just respond with a not found and close the connection HttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND); HttpUtil.setContentLength(response, 0); HttpUtil.setKeepAlive(response, false); ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); } else { // If already responded, just close the connection ctx.channel().close(); } } } finally { ReferenceCountUtil.release(msg); } }
java
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { if (exceptionRaised.get()) { return; } if (!(msg instanceof HttpRequest)) { // If there is no methodInfo, it means the request was already rejected. // What we received here is just residue of the request, which can be ignored. if (methodInfo != null) { ReferenceCountUtil.retain(msg); ctx.fireChannelRead(msg); } return; } HttpRequest request = (HttpRequest) msg; BasicHttpResponder responder = new BasicHttpResponder(ctx.channel(), sslEnabled); // Reset the methodInfo for the incoming request error handling methodInfo = null; methodInfo = prepareHandleMethod(request, responder, ctx); if (methodInfo != null) { ReferenceCountUtil.retain(msg); ctx.fireChannelRead(msg); } else { if (!responder.isResponded()) { // If not yet responded, just respond with a not found and close the connection HttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND); HttpUtil.setContentLength(response, 0); HttpUtil.setKeepAlive(response, false); ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); } else { // If already responded, just close the connection ctx.channel().close(); } } } finally { ReferenceCountUtil.release(msg); } }
[ "@", "Override", "public", "void", "channelRead", "(", "ChannelHandlerContext", "ctx", ",", "Object", "msg", ")", "throws", "Exception", "{", "try", "{", "if", "(", "exceptionRaised", ".", "get", "(", ")", ")", "{", "return", ";", "}", "if", "(", "!", "(", "msg", "instanceof", "HttpRequest", ")", ")", "{", "// If there is no methodInfo, it means the request was already rejected.", "// What we received here is just residue of the request, which can be ignored.", "if", "(", "methodInfo", "!=", "null", ")", "{", "ReferenceCountUtil", ".", "retain", "(", "msg", ")", ";", "ctx", ".", "fireChannelRead", "(", "msg", ")", ";", "}", "return", ";", "}", "HttpRequest", "request", "=", "(", "HttpRequest", ")", "msg", ";", "BasicHttpResponder", "responder", "=", "new", "BasicHttpResponder", "(", "ctx", ".", "channel", "(", ")", ",", "sslEnabled", ")", ";", "// Reset the methodInfo for the incoming request error handling", "methodInfo", "=", "null", ";", "methodInfo", "=", "prepareHandleMethod", "(", "request", ",", "responder", ",", "ctx", ")", ";", "if", "(", "methodInfo", "!=", "null", ")", "{", "ReferenceCountUtil", ".", "retain", "(", "msg", ")", ";", "ctx", ".", "fireChannelRead", "(", "msg", ")", ";", "}", "else", "{", "if", "(", "!", "responder", ".", "isResponded", "(", ")", ")", "{", "// If not yet responded, just respond with a not found and close the connection", "HttpResponse", "response", "=", "new", "DefaultFullHttpResponse", "(", "HttpVersion", ".", "HTTP_1_1", ",", "HttpResponseStatus", ".", "NOT_FOUND", ")", ";", "HttpUtil", ".", "setContentLength", "(", "response", ",", "0", ")", ";", "HttpUtil", ".", "setKeepAlive", "(", "response", ",", "false", ")", ";", "ctx", ".", "channel", "(", ")", ".", "writeAndFlush", "(", "response", ")", ".", "addListener", "(", "ChannelFutureListener", ".", "CLOSE", ")", ";", "}", "else", "{", "// If already responded, just close the connection", "ctx", ".", "channel", "(", ")", ".", "close", "(", ")", ";", "}", "}", "}", "finally", "{", "ReferenceCountUtil", ".", "release", "(", "msg", ")", ";", "}", "}" ]
If the HttpRequest is valid and handled it will be sent upstream, if it cannot be invoked the response will be written back immediately.
[ "If", "the", "HttpRequest", "is", "valid", "and", "handled", "it", "will", "be", "sent", "upstream", "if", "it", "cannot", "be", "invoked", "the", "response", "will", "be", "written", "back", "immediately", "." ]
02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f
https://github.com/cdapio/netty-http/blob/02fdbb45bdd51d3dd58c0efbb2f27195d265cd0f/src/main/java/io/cdap/http/internal/RequestRouter.java#L67-L108