Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions api/openapi.codegen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4815,6 +4815,21 @@ paths:
- integer
- 'null'
format: int64
- name: file_id
in: query
required: false
schema:
type:
- integer
- 'null'
format: int64
- name: entity_id
in: query
required: false
schema:
type:
- string
- 'null'
- name: sort_by
in: query
required: false
Expand Down
15 changes: 15 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4815,6 +4815,21 @@ paths:
- integer
- 'null'
format: int64
- name: file_id
in: query
required: false
schema:
type:
- integer
- 'null'
format: int64
- name: entity_id
in: query
required: false
schema:
type:
- string
- 'null'
- name: sort_by
in: query
required: false
Expand Down
14 changes: 9 additions & 5 deletions julia_client/Torc/src/api/apis/api_RoCrateEntitiesApi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ const _returntypes_list_ro_crate_entities_RoCrateEntitiesApi = Dict{Regex,Type}(
Regex("^" * replace("500", "x"=>".") * "\$") => ErrorResponse,
)

function _oacinternal_list_ro_crate_entities(_api::RoCrateEntitiesApi, id::Int64; offset=nothing, limit=nothing, sort_by=nothing, reverse_sort=nothing, _mediaType=nothing)
function _oacinternal_list_ro_crate_entities(_api::RoCrateEntitiesApi, id::Int64; offset=nothing, limit=nothing, file_id=nothing, entity_id=nothing, sort_by=nothing, reverse_sort=nothing, _mediaType=nothing)
_ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_list_ro_crate_entities_RoCrateEntitiesApi, "/workflows/{id}/ro_crate_entities", [])
OpenAPI.Clients.set_param(_ctx.path, "id", id) # type Int64
OpenAPI.Clients.set_param(_ctx.query, "offset", offset; style="form", is_explode=true) # type Int64
OpenAPI.Clients.set_param(_ctx.query, "limit", limit; style="form", is_explode=true) # type Int64
OpenAPI.Clients.set_param(_ctx.query, "file_id", file_id; style="form", is_explode=true) # type Int64
OpenAPI.Clients.set_param(_ctx.query, "entity_id", entity_id; style="form", is_explode=true) # type String
OpenAPI.Clients.set_param(_ctx.query, "sort_by", sort_by; style="form", is_explode=true) # type String
OpenAPI.Clients.set_param(_ctx.query, "reverse_sort", reverse_sort; style="form", is_explode=true) # type Bool
OpenAPI.Clients.set_header_accept(_ctx, ["application/json", ])
Expand All @@ -154,18 +156,20 @@ end
- id::Int64 (required)
- offset::Int64
- limit::Int64
- file_id::Int64
- entity_id::String
- sort_by::String
- reverse_sort::Bool

Return: ListRoCrateEntitiesResponse, OpenAPI.Clients.ApiResponse
"""
function list_ro_crate_entities(_api::RoCrateEntitiesApi, id::Int64; offset=nothing, limit=nothing, sort_by=nothing, reverse_sort=nothing, _mediaType=nothing)
_ctx = _oacinternal_list_ro_crate_entities(_api, id; offset=offset, limit=limit, sort_by=sort_by, reverse_sort=reverse_sort, _mediaType=_mediaType)
function list_ro_crate_entities(_api::RoCrateEntitiesApi, id::Int64; offset=nothing, limit=nothing, file_id=nothing, entity_id=nothing, sort_by=nothing, reverse_sort=nothing, _mediaType=nothing)
_ctx = _oacinternal_list_ro_crate_entities(_api, id; offset=offset, limit=limit, file_id=file_id, entity_id=entity_id, sort_by=sort_by, reverse_sort=reverse_sort, _mediaType=_mediaType)
return OpenAPI.Clients.exec(_ctx)
end

function list_ro_crate_entities(_api::RoCrateEntitiesApi, response_stream::Channel, id::Int64; offset=nothing, limit=nothing, sort_by=nothing, reverse_sort=nothing, _mediaType=nothing)
_ctx = _oacinternal_list_ro_crate_entities(_api, id; offset=offset, limit=limit, sort_by=sort_by, reverse_sort=reverse_sort, _mediaType=_mediaType)
function list_ro_crate_entities(_api::RoCrateEntitiesApi, response_stream::Channel, id::Int64; offset=nothing, limit=nothing, file_id=nothing, entity_id=nothing, sort_by=nothing, reverse_sort=nothing, _mediaType=nothing)
_ctx = _oacinternal_list_ro_crate_entities(_api, id; offset=offset, limit=limit, file_id=file_id, entity_id=entity_id, sort_by=sort_by, reverse_sort=reverse_sort, _mediaType=_mediaType)
return OpenAPI.Clients.exec(_ctx, response_stream)
end

Expand Down
6 changes: 4 additions & 2 deletions julia_client/julia_client/docs/RoCrateEntitiesApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)

# **list_ro_crate_entities**
> list_ro_crate_entities(_api::RoCrateEntitiesApi, id::Int64; offset=nothing, limit=nothing, sort_by=nothing, reverse_sort=nothing, _mediaType=nothing) -> ListRoCrateEntitiesResponse, OpenAPI.Clients.ApiResponse <br/>
> list_ro_crate_entities(_api::RoCrateEntitiesApi, response_stream::Channel, id::Int64; offset=nothing, limit=nothing, sort_by=nothing, reverse_sort=nothing, _mediaType=nothing) -> Channel{ ListRoCrateEntitiesResponse }, OpenAPI.Clients.ApiResponse
> list_ro_crate_entities(_api::RoCrateEntitiesApi, id::Int64; offset=nothing, limit=nothing, file_id=nothing, entity_id=nothing, sort_by=nothing, reverse_sort=nothing, _mediaType=nothing) -> ListRoCrateEntitiesResponse, OpenAPI.Clients.ApiResponse <br/>
> list_ro_crate_entities(_api::RoCrateEntitiesApi, response_stream::Channel, id::Int64; offset=nothing, limit=nothing, file_id=nothing, entity_id=nothing, sort_by=nothing, reverse_sort=nothing, _mediaType=nothing) -> Channel{ ListRoCrateEntitiesResponse }, OpenAPI.Clients.ApiResponse



Expand All @@ -143,6 +143,8 @@ Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**offset** | **Int64** | | [default to nothing]
**limit** | **Int64** | | [default to nothing]
**file_id** | **Int64** | | [default to nothing]
**entity_id** | **String** | | [default to nothing]
**sort_by** | **String** | | [default to nothing]
**reverse_sort** | **Bool** | | [default to nothing]

Expand Down
34 changes: 34 additions & 0 deletions python_client/src/torc/openapi_client/api/ro_crate_entities_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,8 @@ def list_ro_crate_entities(
id: Annotated[StrictInt, Field(description="Workflow ID")],
offset: Optional[StrictInt] = None,
limit: Optional[StrictInt] = None,
file_id: Optional[StrictInt] = None,
entity_id: Optional[StrictStr] = None,
sort_by: Optional[StrictStr] = None,
reverse_sort: Optional[StrictBool] = None,
_request_timeout: Union[
Expand All @@ -1152,6 +1154,10 @@ def list_ro_crate_entities(
:type offset: int
:param limit:
:type limit: int
:param file_id:
:type file_id: int
:param entity_id:
:type entity_id: str
:param sort_by:
:type sort_by: str
:param reverse_sort:
Expand Down Expand Up @@ -1182,6 +1188,8 @@ def list_ro_crate_entities(
id=id,
offset=offset,
limit=limit,
file_id=file_id,
entity_id=entity_id,
sort_by=sort_by,
reverse_sort=reverse_sort,
_request_auth=_request_auth,
Expand Down Expand Up @@ -1213,6 +1221,8 @@ def list_ro_crate_entities_with_http_info(
id: Annotated[StrictInt, Field(description="Workflow ID")],
offset: Optional[StrictInt] = None,
limit: Optional[StrictInt] = None,
file_id: Optional[StrictInt] = None,
entity_id: Optional[StrictStr] = None,
sort_by: Optional[StrictStr] = None,
reverse_sort: Optional[StrictBool] = None,
_request_timeout: Union[
Expand All @@ -1237,6 +1247,10 @@ def list_ro_crate_entities_with_http_info(
:type offset: int
:param limit:
:type limit: int
:param file_id:
:type file_id: int
:param entity_id:
:type entity_id: str
:param sort_by:
:type sort_by: str
:param reverse_sort:
Expand Down Expand Up @@ -1267,6 +1281,8 @@ def list_ro_crate_entities_with_http_info(
id=id,
offset=offset,
limit=limit,
file_id=file_id,
entity_id=entity_id,
sort_by=sort_by,
reverse_sort=reverse_sort,
_request_auth=_request_auth,
Expand Down Expand Up @@ -1298,6 +1314,8 @@ def list_ro_crate_entities_without_preload_content(
id: Annotated[StrictInt, Field(description="Workflow ID")],
offset: Optional[StrictInt] = None,
limit: Optional[StrictInt] = None,
file_id: Optional[StrictInt] = None,
entity_id: Optional[StrictStr] = None,
sort_by: Optional[StrictStr] = None,
reverse_sort: Optional[StrictBool] = None,
_request_timeout: Union[
Expand All @@ -1322,6 +1340,10 @@ def list_ro_crate_entities_without_preload_content(
:type offset: int
:param limit:
:type limit: int
:param file_id:
:type file_id: int
:param entity_id:
:type entity_id: str
:param sort_by:
:type sort_by: str
:param reverse_sort:
Expand Down Expand Up @@ -1352,6 +1374,8 @@ def list_ro_crate_entities_without_preload_content(
id=id,
offset=offset,
limit=limit,
file_id=file_id,
entity_id=entity_id,
sort_by=sort_by,
reverse_sort=reverse_sort,
_request_auth=_request_auth,
Expand All @@ -1378,6 +1402,8 @@ def _list_ro_crate_entities_serialize(
id,
offset,
limit,
file_id,
entity_id,
sort_by,
reverse_sort,
_request_auth,
Expand Down Expand Up @@ -1412,6 +1438,14 @@ def _list_ro_crate_entities_serialize(

_query_params.append(('limit', limit))

if file_id is not None:

_query_params.append(('file_id', file_id))

if entity_id is not None:

_query_params.append(('entity_id', entity_id))

if sort_by is not None:

_query_params.append(('sort_by', sort_by))
Expand Down
90 changes: 90 additions & 0 deletions src/client/apis/ro_crate_api.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use log::warn;

pub use super::ro_crate_entities_api::{
CreateRoCrateEntityError, DeleteRoCrateEntitiesError, DeleteRoCrateEntityError,
GetRoCrateEntityError, ListRoCrateEntitiesError, UpdateRoCrateEntityError,
Expand All @@ -7,6 +9,94 @@ pub use super::ro_crate_entities_api::{
use super::{Error, configuration, ro_crate_entities_api};
use crate::models;

#[allow(clippy::too_many_arguments)]
pub fn list_ro_crate_entities_with_filters(
configuration: &configuration::Configuration,
id: i64,
offset: Option<i64>,
limit: Option<i64>,
file_id: Option<i64>,
entity_id: Option<&str>,
sort_by: Option<&str>,
reverse_sort: Option<bool>,
) -> Result<models::ListRoCrateEntitiesResponse, Error<ListRoCrateEntitiesError>> {
ro_crate_entities_api::list_ro_crate_entities(
configuration,
id,
offset,
limit,
file_id,
entity_id,
sort_by,
reverse_sort,
)
}

fn first_entity_from_filtered_response(
response: models::ListRoCrateEntitiesResponse,
filter_name: &str,
filter_value: impl std::fmt::Display,
) -> Option<models::RoCrateEntityModel> {
if response.total_count > 1 {
warn!(
"Expected at most one RO-Crate entity for {}={}, found {}. Returning the first match.",
filter_name, filter_value, response.total_count
);
}

response.items.into_iter().next()
}

/// Find the first RO-Crate entity linked to a file.
///
/// If multiple entities match, logs a warning and returns the first item.
pub fn find_ro_crate_entity_by_file_id(
configuration: &configuration::Configuration,
workflow_id: i64,
file_id: i64,
) -> Result<Option<models::RoCrateEntityModel>, Error<ListRoCrateEntitiesError>> {
let response = list_ro_crate_entities_with_filters(
configuration,
workflow_id,
Some(0),
Some(2),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 2?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if for whatever reason multiple docs wiith the same file_id exist we can log a warning

Some(file_id),
None,
None,
None,
)?;

Ok(first_entity_from_filtered_response(
response, "file_id", file_id,
))
}

/// Find the first RO-Crate entity with a matching entity ID.
///
/// If multiple entities match, logs a warning and returns the first item.
pub fn find_ro_crate_entity_by_entity_id(
configuration: &configuration::Configuration,
workflow_id: i64,
entity_id: &str,
) -> Result<Option<models::RoCrateEntityModel>, Error<ListRoCrateEntitiesError>> {
let response = list_ro_crate_entities_with_filters(
configuration,
workflow_id,
Some(0),
Some(2),
None,
Some(entity_id),
None,
None,
)?;

Ok(first_entity_from_filtered_response(
response,
"entity_id",
entity_id,
))
}

pub fn delete_ro_crate_entities(
configuration: &configuration::Configuration,
id: i64,
Expand Down
10 changes: 10 additions & 0 deletions src/client/apis/ro_crate_entities_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,17 @@ pub fn list_ro_crate_entities(
id: i64,
offset: Option<i64>,
limit: Option<i64>,
file_id: Option<i64>,
entity_id: Option<&str>,
sort_by: Option<&str>,
reverse_sort: Option<bool>,
) -> Result<models::ListRoCrateEntitiesResponse, Error<ListRoCrateEntitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_id = id;
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_file_id = file_id;
let p_query_entity_id = entity_id;
let p_query_sort_by = sort_by;
let p_query_reverse_sort = reverse_sort;

Expand All @@ -331,6 +335,12 @@ pub fn list_ro_crate_entities(
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
}
if let Some(ref param_value) = p_query_file_id {
req_builder = req_builder.query(&[("file_id", &param_value.to_string())]);
}
if let Some(ref param_value) = p_query_entity_id {
req_builder = req_builder.query(&[("entity_id", &param_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort_by {
req_builder = req_builder.query(&[("sort_by", &param_value.to_string())]);
}
Expand Down
2 changes: 2 additions & 0 deletions src/client/commands/pagination/ro_crate_entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ impl Paginatable for RoCrateEntityModel {
params.workflow_id,
Some(params.offset),
Some(limit),
None,
None,
params.sort_by(),
params.reverse_sort(),
)?;
Expand Down
2 changes: 2 additions & 0 deletions src/client/commands/workflows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3090,6 +3090,8 @@ fn handle_export(
None,
None,
None,
None,
None,
) {
Ok(response) => response.items,
Err(e) => {
Expand Down
16 changes: 4 additions & 12 deletions src/client/ro_crate_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,8 @@ pub fn find_entity_for_file(
workflow_id: i64,
file_id: i64,
) -> Option<RoCrateEntityModel> {
match apis::ro_crate_entities_api::list_ro_crate_entities(
config,
workflow_id,
None,
None,
None,
None,
) {
Ok(response) => response
.items
.into_iter()
.find(|e| e.file_id == Some(file_id)),
match apis::ro_crate_api::find_ro_crate_entity_by_file_id(config, workflow_id, file_id) {
Ok(entity) => entity,
Err(e) => {
warn!("Failed to check for existing RO-Crate entities: {}", e);
None
Expand Down Expand Up @@ -555,6 +545,8 @@ pub fn create_software_entities(config: &Configuration, workflow_id: i64, run_id
None,
None,
None,
None,
None,
) {
Ok(response) => response.items.into_iter().map(|e| e.entity_id).collect(),
Err(e) => {
Expand Down
Loading
Loading