Skip to content

Commit d242ac0

Browse files
committed
feat(artifact): add delete artifact API command
1 parent 7e4fe71 commit d242ac0

File tree

12 files changed

+575
-26
lines changed

12 files changed

+575
-26
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ All URIs are relative to *https://api.pollination.cloud*
9898
Class | Method | HTTP request | Description
9999
------------ | ------------- | ------------- | -------------
100100
*ArtifactsApi* | [**create**](https://github.com/pollination/python-sdk/blob/master/docs/ArtifactsApi.md#create) | **POST** /artifacts | Get an Artifact upload link.
101+
*ArtifactsApi* | [**delete**](https://github.com/pollination/python-sdk/blob/master/docs/ArtifactsApi.md#delete) | **DELETE** /artifacts | Delete one or many artifacts by key/prefix
101102
*ArtifactsApi* | [**list**](https://github.com/pollination/python-sdk/blob/master/docs/ArtifactsApi.md#list) | **GET** /artifacts | List artifacts in user folder
102103
*AuthenticationApi* | [**create_api_token**](https://github.com/pollination/python-sdk/blob/master/docs/AuthenticationApi.md#create_api_token) | **POST** /auth/api-token | Create an API Token
103104
*AuthenticationApi* | [**delete_api_token**](https://github.com/pollination/python-sdk/blob/master/docs/AuthenticationApi.md#delete_api_token) | **DELETE** /auth/api-token | Delete an API Token
@@ -164,6 +165,7 @@ Class | Method | HTTP request | Description
164165
- [Parameter](https://github.com/pollination/python-sdk/blob/master/docs/Parameter.md)
165166
- [Parent](https://github.com/pollination/python-sdk/blob/master/docs/Parent.md)
166167
- [Plastic](https://github.com/pollination/python-sdk/blob/master/docs/Plastic.md)
168+
- [Query](https://github.com/pollination/python-sdk/blob/master/docs/Query.md)
167169
- [ReferenceWorkflow](https://github.com/pollination/python-sdk/blob/master/docs/ReferenceWorkflow.md)
168170
- [RunFolderLocation](https://github.com/pollination/python-sdk/blob/master/docs/RunFolderLocation.md)
169171
- [S3Location](https://github.com/pollination/python-sdk/blob/master/docs/S3Location.md)
@@ -178,6 +180,7 @@ Class | Method | HTTP request | Description
178180
- [TaskStatus](https://github.com/pollination/python-sdk/blob/master/docs/TaskStatus.md)
179181
- [Token](https://github.com/pollination/python-sdk/blob/master/docs/Token.md)
180182
- [Transparent](https://github.com/pollination/python-sdk/blob/master/docs/Transparent.md)
183+
- [UpdateAccepted](https://github.com/pollination/python-sdk/blob/master/docs/UpdateAccepted.md)
181184
- [ValidationError](https://github.com/pollination/python-sdk/blob/master/docs/ValidationError.md)
182185
- [Vertex](https://github.com/pollination/python-sdk/blob/master/docs/Vertex.md)
183186
- [Workflow](https://github.com/pollination/python-sdk/blob/master/docs/Workflow.md)

docs/ArtifactsApi.md

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All URIs are relative to *https://api.pollination.cloud*
55
Method | HTTP request | Description
66
------------- | ------------- | -------------
77
[**create**](ArtifactsApi.md#create) | **POST** /artifacts | Get an Artifact upload link.
8+
[**delete**](ArtifactsApi.md#delete) | **DELETE** /artifacts | Delete one or many artifacts by key/prefix
89
[**list**](ArtifactsApi.md#list) | **GET** /artifacts | List artifacts in user folder
910

1011

@@ -13,7 +14,7 @@ Method | HTTP request | Description
1314
1415
Get an Artifact upload link.
1516

16-
Create a new workflow.
17+
Create a new artifact.
1718

1819
### Example
1920

@@ -82,8 +83,82 @@ Name | Type | Description | Notes
8283

8384
[[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)
8485

86+
# **delete**
87+
> UpdateAccepted delete(query)
88+
89+
Delete one or many artifacts by key/prefix
90+
91+
Delete one or multiple artifacts based on key prefix
92+
93+
### Example
94+
95+
* Bearer Authentication (JWT):
96+
```python
97+
from __future__ import print_function
98+
import time
99+
import pollination_sdk
100+
from pollination_sdk.rest import ApiException
101+
from pprint import pprint
102+
configuration = pollination_sdk.Configuration()
103+
104+
# Retrieve a temporary Acces Token (JWT) using your API key id and secret
105+
API_KEY_ID = 'some-long-id'
106+
API_KEY_SECRET = 'some-long-secret'
107+
108+
auth = pollination_sdk.AuthenticationApi()
109+
api_token = pollination_sdk.Token(
110+
id=API_KEY_ID,
111+
secret=API_KEY_SECRET
112+
)
113+
114+
auth_response = auth.login(token)
115+
116+
# Configure Bearer authorization: JWT
117+
configuration.access_token = auth_response.access_token
118+
119+
# Defining host is optional and default to https://api.pollination.cloud
120+
configuration.host = "https://api.pollination.cloud"
121+
# Create an instance of the API class
122+
api_instance = pollination_sdk.ArtifactsApi(pollination_sdk.ApiClient(configuration))
123+
query = pollination_sdk.Query() # Query |
124+
125+
try:
126+
# Delete one or many artifacts by key/prefix
127+
api_response = api_instance.delete(query)
128+
pprint(api_response)
129+
except ApiException as e:
130+
print("Exception when calling ArtifactsApi->delete: %s\n" % e)
131+
```
132+
133+
### Parameters
134+
135+
Name | Type | Description | Notes
136+
------------- | ------------- | ------------- | -------------
137+
**query** | [**Query**](Query.md)| |
138+
139+
### Return type
140+
141+
[**UpdateAccepted**](UpdateAccepted.md)
142+
143+
### Authorization
144+
145+
[JWT](../README.md#JWT)
146+
147+
### HTTP request headers
148+
149+
- **Content-Type**: application/json
150+
- **Accept**: application/json
151+
152+
### HTTP response details
153+
| Status code | Description | Response headers |
154+
|-------------|-------------|------------------|
155+
**202** | Successful Response | - |
156+
**422** | Validation Error | - |
157+
158+
[[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)
159+
85160
# **list**
86-
> list[FileMeta] list(page=page, per_page=per_page)
161+
> list[FileMeta] list()
87162
88163
List artifacts in user folder
89164

@@ -119,23 +194,17 @@ configuration.access_token = auth_response.access_token
119194
configuration.host = "https://api.pollination.cloud"
120195
# Create an instance of the API class
121196
api_instance = pollination_sdk.ArtifactsApi(pollination_sdk.ApiClient(configuration))
122-
page = 1 # int | Page number starting from 1 (optional) (default to 1)
123-
per_page = 25 # int | Number of items per page (optional) (default to 25)
124197

125198
try:
126199
# List artifacts in user folder
127-
api_response = api_instance.list(page=page, per_page=per_page)
200+
api_response = api_instance.list()
128201
pprint(api_response)
129202
except ApiException as e:
130203
print("Exception when calling ArtifactsApi->list: %s\n" % e)
131204
```
132205

133206
### Parameters
134-
135-
Name | Type | Description | Notes
136-
------------- | ------------- | ------------- | -------------
137-
**page** | **int**| Page number starting from 1 | [optional] [default to 1]
138-
**per_page** | **int**| Number of items per page | [optional] [default to 25]
207+
This endpoint does not need any parameter.
139208

140209
### Return type
141210

@@ -158,7 +227,6 @@ Name | Type | Description | Notes
158227
**500** | Server error | - |
159228
**404** | Not found | - |
160229
**200** | Retrieved | * Link - The Link header with pagination information. For details see [link header](https://pollination.cloud/api/#section/Pagination/Link-header). <br> |
161-
**422** | Validation Error | - |
162230

163231
[[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)
164232

docs/Query.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Query
2+
3+
Query parameters for list based resource access
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**ids** | **list[str]** | | [optional] [default to []]
8+
**prefix** | **str** | | [optional]
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+
12+

docs/UpdateAccepted.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# UpdateAccepted
2+
3+
Accepted request response for existing resource
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**status** | **str** | | [optional] [default to 'accepted']
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+
11+

pollination_sdk/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
from pollination_sdk.models.parameter import Parameter
6464
from pollination_sdk.models.parent import Parent
6565
from pollination_sdk.models.plastic import Plastic
66+
from pollination_sdk.models.query import Query
6667
from pollination_sdk.models.reference_workflow import ReferenceWorkflow
6768
from pollination_sdk.models.run_folder_location import RunFolderLocation
6869
from pollination_sdk.models.s3_location import S3Location
@@ -77,6 +78,7 @@
7778
from pollination_sdk.models.task_status import TaskStatus
7879
from pollination_sdk.models.token import Token
7980
from pollination_sdk.models.transparent import Transparent
81+
from pollination_sdk.models.update_accepted import UpdateAccepted
8082
from pollination_sdk.models.validation_error import ValidationError
8183
from pollination_sdk.models.vertex import Vertex
8284
from pollination_sdk.models.workflow import Workflow

pollination_sdk/api/artifacts_api.py

Lines changed: 115 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, api_client=None):
3939
def create(self, key_request, **kwargs): # noqa: E501
4040
"""Get an Artifact upload link. # noqa: E501
4141
42-
Create a new workflow. # noqa: E501
42+
Create a new artifact. # noqa: E501
4343
This method makes a synchronous HTTP request by default. To make an
4444
asynchronous HTTP request, please pass async_req=True
4545
>>> thread = api.create(key_request, async_req=True)
@@ -64,7 +64,7 @@ def create(self, key_request, **kwargs): # noqa: E501
6464
def create_with_http_info(self, key_request, **kwargs): # noqa: E501
6565
"""Get an Artifact upload link. # noqa: E501
6666
67-
Create a new workflow. # noqa: E501
67+
Create a new artifact. # noqa: E501
6868
This method makes a synchronous HTTP request by default. To make an
6969
asynchronous HTTP request, please pass async_req=True
7070
>>> thread = api.create_with_http_info(key_request, async_req=True)
@@ -148,6 +148,118 @@ def create_with_http_info(self, key_request, **kwargs): # noqa: E501
148148
_request_timeout=local_var_params.get('_request_timeout'),
149149
collection_formats=collection_formats)
150150

151+
def delete(self, query, **kwargs): # noqa: E501
152+
"""Delete one or many artifacts by key/prefix # noqa: E501
153+
154+
Delete one or multiple artifacts based on key prefix # noqa: E501
155+
This method makes a synchronous HTTP request by default. To make an
156+
asynchronous HTTP request, please pass async_req=True
157+
>>> thread = api.delete(query, async_req=True)
158+
>>> result = thread.get()
159+
160+
:param async_req bool: execute request asynchronously
161+
:param Query query: (required)
162+
:param _preload_content: if False, the urllib3.HTTPResponse object will
163+
be returned without reading/decoding response
164+
data. Default is True.
165+
:param _request_timeout: timeout setting for this request. If one
166+
number provided, it will be total request
167+
timeout. It can also be a pair (tuple) of
168+
(connection, read) timeouts.
169+
:return: UpdateAccepted
170+
If the method is called asynchronously,
171+
returns the request thread.
172+
"""
173+
kwargs['_return_http_data_only'] = True
174+
return self.delete_with_http_info(query, **kwargs) # noqa: E501
175+
176+
def delete_with_http_info(self, query, **kwargs): # noqa: E501
177+
"""Delete one or many artifacts by key/prefix # noqa: E501
178+
179+
Delete one or multiple artifacts based on key prefix # noqa: E501
180+
This method makes a synchronous HTTP request by default. To make an
181+
asynchronous HTTP request, please pass async_req=True
182+
>>> thread = api.delete_with_http_info(query, async_req=True)
183+
>>> result = thread.get()
184+
185+
:param async_req bool: execute request asynchronously
186+
:param Query query: (required)
187+
:param _return_http_data_only: response data without head status code
188+
and headers
189+
:param _preload_content: if False, the urllib3.HTTPResponse object will
190+
be returned without reading/decoding response
191+
data. Default is True.
192+
:param _request_timeout: timeout setting for this request. If one
193+
number provided, it will be total request
194+
timeout. It can also be a pair (tuple) of
195+
(connection, read) timeouts.
196+
:return: tuple(UpdateAccepted, status_code(int), headers(HTTPHeaderDict))
197+
If the method is called asynchronously,
198+
returns the request thread.
199+
"""
200+
201+
local_var_params = locals()
202+
203+
all_params = ['query'] # noqa: E501
204+
all_params.append('async_req')
205+
all_params.append('_return_http_data_only')
206+
all_params.append('_preload_content')
207+
all_params.append('_request_timeout')
208+
209+
for key, val in six.iteritems(local_var_params['kwargs']):
210+
if key not in all_params:
211+
raise ApiTypeError(
212+
"Got an unexpected keyword argument '%s'"
213+
" to method delete" % key
214+
)
215+
local_var_params[key] = val
216+
del local_var_params['kwargs']
217+
# verify the required parameter 'query' is set
218+
if self.api_client.client_side_validation and ('query' not in local_var_params or # noqa: E501
219+
local_var_params['query'] is None): # noqa: E501
220+
raise ApiValueError("Missing the required parameter `query` when calling `delete`") # noqa: E501
221+
222+
collection_formats = {}
223+
224+
path_params = {}
225+
226+
query_params = []
227+
228+
header_params = {}
229+
230+
form_params = []
231+
local_var_files = {}
232+
233+
body_params = None
234+
if 'query' in local_var_params:
235+
body_params = local_var_params['query']
236+
# HTTP header `Accept`
237+
header_params['Accept'] = self.api_client.select_header_accept(
238+
['application/json']) # noqa: E501
239+
240+
# HTTP header `Content-Type`
241+
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
242+
['application/json']) # noqa: E501
243+
244+
# Authentication setting
245+
auth_settings = ['JWT'] # noqa: E501
246+
247+
return self.api_client.call_api(
248+
'/artifacts', 'DELETE',
249+
path_params,
250+
query_params,
251+
header_params,
252+
body=body_params,
253+
post_params=form_params,
254+
files=local_var_files,
255+
response_type='UpdateAccepted', # noqa: E501
256+
auth_settings=auth_settings,
257+
async_req=local_var_params.get('async_req'),
258+
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
259+
_preload_content=local_var_params.get('_preload_content', True),
260+
_request_timeout=local_var_params.get('_request_timeout'),
261+
collection_formats=collection_formats)
262+
151263
def list(self, **kwargs): # noqa: E501
152264
"""List artifacts in user folder # noqa: E501
153265
@@ -158,8 +270,6 @@ def list(self, **kwargs): # noqa: E501
158270
>>> result = thread.get()
159271
160272
:param async_req bool: execute request asynchronously
161-
:param int page: Page number starting from 1
162-
:param int per_page: Number of items per page
163273
:param _preload_content: if False, the urllib3.HTTPResponse object will
164274
be returned without reading/decoding response
165275
data. Default is True.
@@ -184,8 +294,6 @@ def list_with_http_info(self, **kwargs): # noqa: E501
184294
>>> result = thread.get()
185295
186296
:param async_req bool: execute request asynchronously
187-
:param int page: Page number starting from 1
188-
:param int per_page: Number of items per page
189297
:param _return_http_data_only: response data without head status code
190298
and headers
191299
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -202,7 +310,7 @@ def list_with_http_info(self, **kwargs): # noqa: E501
202310

203311
local_var_params = locals()
204312

205-
all_params = ['page', 'per_page'] # noqa: E501
313+
all_params = [] # noqa: E501
206314
all_params.append('async_req')
207315
all_params.append('_return_http_data_only')
208316
all_params.append('_preload_content')
@@ -217,19 +325,11 @@ def list_with_http_info(self, **kwargs): # noqa: E501
217325
local_var_params[key] = val
218326
del local_var_params['kwargs']
219327

220-
if self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1: # noqa: E501
221-
raise ApiValueError("Invalid value for parameter `page` when calling `list`, must be a value greater than or equal to `1`") # noqa: E501
222-
if self.api_client.client_side_validation and 'per_page' in local_var_params and local_var_params['per_page'] > 100: # noqa: E501
223-
raise ApiValueError("Invalid value for parameter `per_page` when calling `list`, must be a value less than or equal to `100`") # noqa: E501
224328
collection_formats = {}
225329

226330
path_params = {}
227331

228332
query_params = []
229-
if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501
230-
query_params.append(('page', local_var_params['page'])) # noqa: E501
231-
if 'per_page' in local_var_params and local_var_params['per_page'] is not None: # noqa: E501
232-
query_params.append(('per-page', local_var_params['per_page'])) # noqa: E501
233333

234334
header_params = {}
235335

pollination_sdk/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from pollination_sdk.models.parameter import Parameter
4545
from pollination_sdk.models.parent import Parent
4646
from pollination_sdk.models.plastic import Plastic
47+
from pollination_sdk.models.query import Query
4748
from pollination_sdk.models.reference_workflow import ReferenceWorkflow
4849
from pollination_sdk.models.run_folder_location import RunFolderLocation
4950
from pollination_sdk.models.s3_location import S3Location
@@ -58,6 +59,7 @@
5859
from pollination_sdk.models.task_status import TaskStatus
5960
from pollination_sdk.models.token import Token
6061
from pollination_sdk.models.transparent import Transparent
62+
from pollination_sdk.models.update_accepted import UpdateAccepted
6163
from pollination_sdk.models.validation_error import ValidationError
6264
from pollination_sdk.models.vertex import Vertex
6365
from pollination_sdk.models.workflow import Workflow

0 commit comments

Comments
 (0)