Skip to content

Commit

Permalink
PR Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrasseur-aneo committed Oct 27, 2023
1 parent 2d55382 commit 51465fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/cpp/ArmoniK.Api.Client/header/tasks/TasksClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TasksClient {
* @param total Output for the total of session available for this request (used for pagination)
* @param page Page to request, use -1 to get all pages.
* @param page_size Size of the requested page, ignored if page is -1
* @param sort How the sessions are sorted, ascending creation date by default
* @param sort How the tasks are sorted, ascending creation date by default
* @return List of tasks summary
*
* @note If the tasks corresponding to the filters change while this call is going for page==-1,
Expand All @@ -40,7 +40,7 @@ class TasksClient {
* @param total Output for the total of session available for this request (used for pagination)
* @param page Page to request, use -1 to get all pages.
* @param page_size Size of the requested page, ignored if page is -1
* @param sort How the sessions are sorted, ascending creation date by default
* @param sort How the tasks are sorted, ascending creation date by default
* @return List of tasks summary
*
* @note If the tasks corresponding to the filters change while this call is going for page==-1,
Expand Down
15 changes: 15 additions & 0 deletions packages/cpp/ArmoniK.Api.Client/source/tasks/TasksClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ static inline ::grpc::Status call_stub_list(armonik::api::grpc::v1::tasks::Tasks
return stub->ListTasks(&context, request, response);
}

/**
* Common function called to list tasks
* @tparam T Result value type (TaskSummary or TaskDetailed
* @tparam U Response type
* @param stub Task stub
* @param filters Filter to be used
* @param total Output for the total of session available for this request (used for pagination)
* @param page Page to request, use -1 to get all pages.
* @param page_size Size of the requested page, ignored if page is -1
* @param sort How the tasks are sorted, ascending creation date by default
* @return Vector of information about the tasks
*/
template <typename T, typename U, class = decltype(std::declval<U>().tasks()),
class = decltype(std::declval<U>().total())>
static std::vector<T> list_tasks_common(armonik::api::grpc::v1::tasks::Tasks::StubInterface *stub,
Expand Down Expand Up @@ -71,13 +83,15 @@ TasksClient::list_tasks(armonik::api::grpc::v1::tasks::Filters filters, int32_t
armonik::api::grpc::v1::tasks::ListTasksResponse>(stub.get(), std::move(filters), total,
page, page_size, std::move(sort));
}

std::vector<armonik::api::grpc::v1::tasks::TaskDetailed>
TasksClient::list_tasks_detailed(armonik::api::grpc::v1::tasks::Filters filters, int32_t &total, int32_t page,
int32_t page_size, armonik::api::grpc::v1::tasks::ListTasksRequest::Sort sort) {
return list_tasks_common<armonik::api::grpc::v1::tasks::TaskDetailed,
armonik::api::grpc::v1::tasks::ListTasksDetailedResponse>(
stub.get(), std::move(filters), total, page, page_size, std::move(sort));
}

armonik::api::grpc::v1::tasks::TaskDetailed TasksClient::get_task(std::string task_id) {
::grpc::ClientContext context;
armonik::api::grpc::v1::tasks::GetTaskRequest request;
Expand Down Expand Up @@ -160,6 +174,7 @@ TasksClient::count_tasks_by_status(armonik::api::grpc::v1::tasks::Filters filter
}
return map_status;
}

std::vector<armonik::api::common::TaskInfo>
TasksClient::submit_tasks(std::string session_id, const std::vector<armonik::api::common::TaskCreation> &task_creations,
const armonik::api::grpc::v1::TaskOptions &task_options) {
Expand Down

0 comments on commit 51465fc

Please sign in to comment.