Commit 1fa94feb authored by Victor Dosda's avatar Victor Dosda
Browse files

Merge branch 'fix_revert_delete_records' into 'master'

add POST /v2/records/delete

See merge request !15
parents 6dab65ff 2d126889
Pipeline #79035 passed with stages
in 40 seconds
......@@ -285,6 +285,51 @@
"profile" ]
} ]
}
},
"/v2/records/delete" : {
"post" : {
"tags" : [ "records" ],
"summary" : "Delete records",
"description" : "The API performs a logical deletion of the given records. This operation can be reverted later. Required roles: 'users.datalake.editors' or 'users.datalake.admins'.",
"operationId" : "Delete records",
"consumes" : [ "application/json" ],
"produces" : [ "application/json" ],
"parameters" : [ {
"name" : "data-partition-id",
"in" : "header",
"description" : "This value should be the desired data partition id.",
"required" : true,
"type" : "string",
"default" : "common"
},
{
"name" : "body",
"in" : "body",
"required" : true,
"schema" : {
"type": "array",
"items" : {
"type" : "string"
}
}
}
],
"responses" : {
"204" : {
"description" : "Records deleted successfully."
},
"404" : {
"description" : "Records not found.",
"schema" : {
"$ref" : "#/definitions/AppError"
}
}
},
"security" : [ {
"google_id_token" : [ "email",
"profile" ]
} ]
}
},
"/v2/records/versions/{id}" : {
"get" : {
......
......@@ -56,6 +56,16 @@ class _RecordsApi:
json=body,
)
def _build_for_delete_records(self, data_partition_id: str, request_body: List[str]) -> Awaitable[None]:
"""
The API performs a logical deletion of the given records. This operation can be reverted later. Required roles: 'users.datalake.editors' or 'users.datalake.admins'.
"""
headers = {"data-partition-id": str(data_partition_id)}
body = jsonable_encoder(request_body)
return self.api_client.request(type_=None, method="POST", url="/v2/records/delete", headers=headers, json=body)
def _build_for_get_all_record_versions(self, id: str, data_partition_id: str) -> Awaitable[m.RecordVersions]:
"""
The API returns a list containing all versions for the given record id. Required roles: 'users.datalake.viewers' or 'users.datalake.editors' or 'users.datalake.admins'.
......@@ -158,6 +168,12 @@ class AsyncRecordsApi(_RecordsApi):
"""
return await self._build_for_delete_record(id=id, data_partition_id=data_partition_id, body=body)
async def delete_records(self, data_partition_id: str, request_body: List[str]) -> None:
"""
The API performs a logical deletion of the given records. This operation can be reverted later. Required roles: 'users.datalake.editors' or 'users.datalake.admins'.
"""
return await self._build_for_delete_records(data_partition_id=data_partition_id, request_body=request_body)
async def get_all_record_versions(self, id: str, data_partition_id: str) -> m.RecordVersions:
"""
The API returns a list containing all versions for the given record id. Required roles: 'users.datalake.viewers' or 'users.datalake.editors' or 'users.datalake.admins'.
......@@ -206,6 +222,13 @@ class SyncRecordsApi(_RecordsApi):
coroutine = self._build_for_delete_record(id=id, data_partition_id=data_partition_id, body=body)
return get_event_loop().run_until_complete(coroutine)
def delete_records(self, data_partition_id: str, request_body: List[str]) -> None:
"""
The API performs a logical deletion of the given records. This operation can be reverted later. Required roles: 'users.datalake.editors' or 'users.datalake.admins'.
"""
coroutine = self._build_for_delete_records(data_partition_id=data_partition_id, request_body=request_body)
return get_event_loop().run_until_complete(coroutine)
def get_all_record_versions(self, id: str, data_partition_id: str) -> m.RecordVersions:
"""
The API returns a list containing all versions for the given record id. Required roles: 'users.datalake.viewers' or 'users.datalake.editors' or 'users.datalake.admins'.
......
......@@ -6,6 +6,7 @@ Method | HTTP request | Description
------------- | ------------- | -------------
[**create_or_update_records**](RecordsApi.md#create_or_update_records) | **PUT** /v2/records | Create or update records
[**delete_record**](RecordsApi.md#delete_record) | **POST** /v2/records/{id}:delete | Delete record
[**delete_records**](RecordsApi.md#delete_records) | **POST** /v2/records/delete | Delete records
[**get_all_record_versions**](RecordsApi.md#get_all_record_versions) | **GET** /v2/records/versions/{id} | Get all record versions
[**get_record**](RecordsApi.md#get_record) | **GET** /v2/records/{id} | Get record
[**get_record_version**](RecordsApi.md#get_record_version) | **GET** /v2/records/{id}/{version} | Get record version
......@@ -143,6 +144,68 @@ void (empty response body)
[[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)
# **delete_records**
> delete_records(data_partition_id, request_body)
Delete records
The API performs a logical deletion of the given records. This operation can be reverted later. Required roles: 'users.datalake.editors' or 'users.datalake.admins'.
### Example
* OAuth Authentication (google_id_token):
```python
from __future__ import print_function
import time
import odes_storage
from odes_storage.rest import ApiException
from pprint import pprint
configuration = odes_storage.Configuration()
# Configure OAuth2 access token for authorization: google_id_token
configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Defining host is optional and default to https://os-storage-dot-opendes.appspot.com/api/storage
configuration.host = "https://os-storage-dot-opendes.appspot.com/api/storage"
# Create an instance of the API class
api_instance = odes_storage.RecordsApi(odes_storage.ApiClient(configuration))
data_partition_id = 'common' # str | This value should be the desired data partition id. (default to 'common')
request_body = ['request_body_example'] # List[str] |
try:
# Delete records
api_instance.delete_records(data_partition_id, request_body)
except ApiException as e:
print("Exception when calling RecordsApi->delete_records: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**data_partition_id** | **str**| This value should be the desired data partition id. | [default to 'common']
**request_body** | [**List[str]**](str.md)| |
### Return type
void (empty response body)
### Authorization
[google_id_token](../README.md#google_id_token)
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**204** | Records deleted successfully. | - |
**404** | Records not found. | - |
[[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)
# **get_all_record_versions**
> RecordVersions get_all_record_versions(id, data_partition_id)
......
......@@ -262,6 +262,44 @@ paths:
- google_id_token:
- email
- profile
/v2/records/delete:
post:
tags:
- records
summary: Delete records
description: "The API performs a logical deletion of the given records. This
operation can be reverted later. Required roles:
'users.datalake.editors' or 'users.datalake.admins'."
operationId: Delete records
parameters:
- name: data-partition-id
in: header
description: This value should be the desired data partition id.
required: true
schema:
type: string
default: common
requestBody:
content:
application/json:
schema:
type: array
items:
type: string
required: true
responses:
"204":
description: Records deleted successfully.
"404":
description: Records not found.
content:
application/json:
schema:
$ref: "#/components/schemas/AppError"
security:
- google_id_token:
- email
- profile
"/v2/records/versions/{id}":
get:
tags:
......
......@@ -9,7 +9,7 @@ with open("README.md", "r") as fh:
long_description = fh.read()
NAME = "osdu-data-ecosystem-storage"
VERSION = "1.2.0"
VERSION = "1.3.0"
# To install the library, run the following
#
# python setup.py install
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment