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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions libraries/client/osbv2-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
__pycache__/
*.py[cod]
*.egg-info/
build/
dist/
.eggs/
.pytest_cache/
.coverage
htmlcov/
5 changes: 5 additions & 0 deletions libraries/client/osbv2-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## [Unreleased]

- Initial packaging scaffolding.
21 changes: 21 additions & 0 deletions libraries/client/osbv2-api/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 OSB authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions libraries/client/osbv2-api/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include README.md
include LICENSE
include CHANGELOG.md
include MANIFEST.in
recursive-include osbv2_api *.py *.md
recursive-include docs *
global-exclude __pycache__ *.pyc
19 changes: 19 additions & 0 deletions libraries/client/osbv2-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# osbv2-api

TODO: Add a project description.

## Installation

```bash
pip install .
```

## Usage

TODO: Add usage examples.

## Development

```bash
pytest
```
7 changes: 7 additions & 0 deletions libraries/client/osbv2-api/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os
import sys

ROOT = os.path.dirname(os.path.abspath(__file__))
OSBV2_API = os.path.join(ROOT, "osbv2_api")
if OSBV2_API not in sys.path:
sys.path.insert(0, OSBV2_API)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# BiomodelsRepositoryResource

figshare repository resource

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | file name | [optional]
**path** | **str** | Download URL of the Resource | [optional]
**osbrepository_id** | **int** | OSB Repository id | [optional]
**size** | **int** | File size in bytes of the RepositoryResource | [optional]
**timestamp_modified** | **datetime** | Date/time the ReposityResource is last modified | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


189 changes: 189 additions & 0 deletions libraries/client/osbv2-api/docs/apidocs/workspaces/DandiApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
# workspaces.DandiApi

All URIs are relative to *http://localhost/api*

Method | HTTP request | Description
------------- | ------------- | -------------
[**get_upload_urls**](DandiApi.md#get_upload_urls) | **POST** /dandi/get_upload_urls | Reserve an upload into a dandiset and return presigned part URLs. OSB builds the asset path from the caller's id.
[**validate_upload**](DandiApi.md#validate_upload) | **POST** /dandi/validate_upload | Complete the multipart upload, validate the blob and register the asset in the dandiset's draft.


# **get_upload_urls**
> DandiUploadUrlsResponse get_upload_urls(dandi_upload_urls_request)

Reserve an upload into a dandiset and return presigned part URLs. OSB builds the asset path from the caller's id.

### Example

* Bearer (JWT) Authentication (bearerAuth):
```python
import time
import workspaces
from workspaces.api import dandi_api
from workspaces.model.dandi_upload_urls_response import DandiUploadUrlsResponse
from workspaces.model.dandi_upload_urls_request import DandiUploadUrlsRequest
from pprint import pprint
# Defining the host is optional and defaults to http://localhost/api
# See configuration.py for a list of all supported configuration parameters.
configuration = workspaces.Configuration(
host = "http://localhost/api"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization (JWT): bearerAuth
configuration = workspaces.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)

# Enter a context with an instance of the API client
with workspaces.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = dandi_api.DandiApi(api_client)
dandi_upload_urls_request = DandiUploadUrlsRequest(
instance="dandi",
username="username_example",
dandiset_id="048072",
filename="filename_example",
size=1,
dandi_etag="dandi_etag_example",
) # DandiUploadUrlsRequest | The file to upload, and the DANDI deployment and dandiset to upload it into.

# example passing only required values which don't have defaults set
try:
# Reserve an upload into a dandiset and return presigned part URLs. OSB builds the asset path from the caller's id.
api_response = api_instance.get_upload_urls(dandi_upload_urls_request)
pprint(api_response)
except workspaces.ApiException as e:
print("Exception when calling DandiApi->get_upload_urls: %s\n" % e)
```


### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**dandi_upload_urls_request** | [**DandiUploadUrlsRequest**](DandiUploadUrlsRequest.md)| The file to upload, and the DANDI deployment and dandiset to upload it into. |

### Return type

[**DandiUploadUrlsResponse**](DandiUploadUrlsResponse.md)

### Authorization

[bearerAuth](../README.md#bearerAuth)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Upload reserved: presigned S3 part URLs the client PUTs to directly, or, when the deployment already holds this content, no parts and the existing blob_id. | - |
**400** | A missing or invalid field, or an unknown instance. | - |
**401** | Missing or invalid OSB token. | - |
**403** | The path does not belong to the caller. | - |
**502** | The DANDI deployment refused or failed the call. | - |
**503** | Uploads are not available (no key for that user, or Keycloak unreachable). | - |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **validate_upload**
> DandiValidateUploadResponse validate_upload(dandi_validate_upload_request)

Complete the multipart upload, validate the blob and register the asset in the dandiset's draft.

### Example

* Bearer (JWT) Authentication (bearerAuth):
```python
import time
import workspaces
from workspaces.api import dandi_api
from workspaces.model.dandi_validate_upload_response import DandiValidateUploadResponse
from workspaces.model.dandi_validate_upload_request import DandiValidateUploadRequest
from pprint import pprint
# Defining the host is optional and defaults to http://localhost/api
# See configuration.py for a list of all supported configuration parameters.
configuration = workspaces.Configuration(
host = "http://localhost/api"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization (JWT): bearerAuth
configuration = workspaces.Configuration(
access_token = 'YOUR_BEARER_TOKEN'
)

# Enter a context with an instance of the API client
with workspaces.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = dandi_api.DandiApi(api_client)
dandi_validate_upload_request = DandiValidateUploadRequest(
instance="dandi",
username="username_example",
dandiset_id="048072",
upload_id="bf325375-e030-fccb-a009-17317c574773",
path="path_example",
parts=[
DandiUploadedPart(
part_number=1,
size=1,
etag="etag_example",
),
],
blob_id="bf325375-e030-fccb-a009-17317c574773",
) # DandiValidateUploadRequest | The parts the client uploaded, to complete, validate and register as an asset.

# example passing only required values which don't have defaults set
try:
# Complete the multipart upload, validate the blob and register the asset in the dandiset's draft.
api_response = api_instance.validate_upload(dandi_validate_upload_request)
pprint(api_response)
except workspaces.ApiException as e:
print("Exception when calling DandiApi->validate_upload: %s\n" % e)
```


### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**dandi_validate_upload_request** | [**DandiValidateUploadRequest**](DandiValidateUploadRequest.md)| The parts the client uploaded, to complete, validate and register as an asset. |

### Return type

[**DandiValidateUploadResponse**](DandiValidateUploadResponse.md)

### Authorization

[bearerAuth](../README.md#bearerAuth)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**201** | Upload completed, validated and registered in the dandiset's draft. | - |
**400** | A missing or invalid field, or an unknown instance. | - |
**401** | Missing or invalid OSB token. | - |
**403** | The path does not belong to the caller. | - |
**502** | The DANDI deployment refused or failed the call. | - |
**503** | Uploads are not available (no key for that user, or Keycloak unreachable). | - |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DandiUploadPart


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**part_number** | **int** | | [optional]
**url** | **str** | Presigned S3 URL the client PUTs this part's bytes to directly. | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# DandiUploadUrlsRequest


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**instance** | **str** | The DANDI deployment, by its dandi-cli name. |
**username** | **str** | Keycloak user whose DANDI_API_KEY attribute signs the upload; the key must belong to that deployment. |
**dandiset_id** | **str** | The dandiset to upload into, chosen by the client. |
**filename** | **str** | |
**size** | **int** | |
**dandi_etag** | **str** | S3-multipart digest in DANDI's format (32 hex chars, a dash, the part count), computed by the client since the bytes never reach this server. |
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# DandiUploadUrlsResponse


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**dandiset_id** | **str** | |
**path** | **str** | Asset path, built by OSB from the caller's id. |
**parts** | [**[DandiUploadPart]**](DandiUploadPart.md) | |
**upload_id** | **str** | Absent when the deployment already held this content. | [optional]
**blob_id** | **str** | Set only when the deployment already held this content (parts is then empty). | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# DandiUploadedPart


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**part_number** | **int** | | [optional]
**size** | **int** | | [optional]
**etag** | **str** | The ETag S3 returned for this part's PUT. | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# DandiValidateUploadRequest


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**instance** | **str** | The DANDI deployment, by its dandi-cli name. |
**username** | **str** | Keycloak user whose DANDI_API_KEY attribute signs the upload; the key must belong to that deployment. |
**dandiset_id** | **str** | |
**path** | **str** | The path get_upload_urls returned. |
**upload_id** | **str** | Omitted when get_upload_urls returned a blob_id (nothing was uploaded). | [optional]
**parts** | [**[DandiUploadedPart]**](DandiUploadedPart.md) | Omitted when get_upload_urls returned a blob_id. | [optional]
**blob_id** | **str** | Echoed from get_upload_urls; when present, complete/validate are skipped. | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# DandiValidateUploadResponse


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**asset_id** | **str** | |
**asset_path** | **str** | |
**download_url** | **str** | Where the asset's bytes can be fetched from, e.g. by OSB's workspace import. |
**dandiset_id** | **str** | | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# InlineResponse2004


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**workspaces** | **int** | | [optional]
**repositories** | **int** | | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Loading
Loading