diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 01b88c3ae1bc2716a62fd5604c875f93c6f46154..68844b85a6dec13a7074c43701513f9207cef78f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,11 @@ default: image: python:3.7-slim-buster + +include: + - project: "osdu/platform/domain-data-mgmt-services/wellbore/lib/lib-registry" + file: "registry-setup.yml" + stages: - test - deploy @@ -23,6 +28,6 @@ deploylib: - pip3 install -r requirements.txt - pip3 install twine - python3 setup.py sdist bdist_wheel - - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=${CI_REGISTRY_USER} python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/* + - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=${CI_REGISTRY_USER} python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${WDMS_LIB_REGISTRY}/packages/pypi dist/* rules: - if: $CI_COMMIT_BRANCH == 'master' diff --git a/curated-swagger-storage.json b/curated-swagger-storage.json index 58df8cfa43d4dd20b6d019de3b108dc7d8e1835a..5e8414fb69545caa0a260e1ea8b7e17736532553 100644 --- a/curated-swagger-storage.json +++ b/curated-swagger-storage.json @@ -922,6 +922,43 @@ "ancestry" : { "description" : "Record ancestry information.", "$ref" : "#/definitions/RecordAncestry" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" } }, "description" : "Storage record", diff --git a/example.py b/example.py index 0f0590ccfae41cc6acc4f28c7bd61d1be4dc05be..74f231d689fe980565af52989bbbd1ecbad1a7bf 100644 --- a/example.py +++ b/example.py @@ -1,15 +1,8 @@ import asyncio from pprint import pprint -from odes_storage import AsyncApis as StorageApi -from odes_storage import AuthApiClient as StorageClient -from odes_storage.models import ( - CreateUpdateRecordsResponse, - DatastoreQueryResult, - Legal, - Record, - StorageAcl, -) +from odes_storage import AsyncApis as StorageApi, AuthApiClient as StorageClient +from odes_storage.models import CreateUpdateRecordsResponse, Legal, Record, StorageAcl HOSTNAME = "https://os-storage-dot-opendes.appspot.com/api/storage" TOKEN = "eyJhbGciOiJSUzI1NiIsImtpZCI6ImY5ZDk3YjRjYWU5MGJjZDc2YWViMjAwMjZmNmI3NzBjYWMyMjE3ODMiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiI0ODk1NzIxMDc2OTUtb2FjajI0ZnRlNWExN3JtM2VsZ2lsaGJuNDljaWVnaG8uYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiI0ODk1NzIxMDc2OTUtb2FjajI0ZnRlNWExN3JtM2VsZ2lsaGJuNDljaWVnaG8uYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDM0MzY5NjA1NjQ3Njk2ODQzMzUiLCJoZCI6Im9wZW5kZXMucDRkLmNsb3VkLnNsYi1kcy5jb20iLCJlbWFpbCI6ImNsYWxsZW1lbnRAb3BlbmRlcy5wNGQuY2xvdWQuc2xiLWRzLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhdF9oYXNoIjoiV1RBb1lVLTI5YTU3QmpOaV9IajNndyIsImlhdCI6MTU4NzU0MDI3NCwiZXhwIjoxNTg3NTQzODc0fQ.l3OljSD9N5FhNRbj8E8Gd3dyDj8Qi40r6W4e473tfTvGHzuE6QLpm5Yhp-l43HHHcOt_Gnbm-hEq6l9XXyx4yGAhna8Wp9vgz2HRlQDcXAB1WeYkBhzJ2PCu8QrT_cqahPzH8pqN8mNuTpEzJTVKZQJIm0Crs9DVz2XyIvCaUxX9lEqHKIzCVeRYjdoBKundRw4WKVXtrLd4ZX56fP9s06aUmHdrdN8BFmSn1JS2I8XNtPHarv_kKiItWbZIjWkjvM_OOCwx38oZUztTBq9W-uMh-nIT59PGj7e_RxtGUiEBlvkZroKvHg1wF1WcPOBQ5-EvW1oU19fjWkhyfbuQFQ" diff --git a/odes_storage/api/records_api.py b/odes_storage/api/records_api.py index 74b1ef7e79d13514480dcd79ce0fc623b32c01f1..fad1eba8a04ff23bd9cfd194dfead2456842d6dc 100644 --- a/odes_storage/api/records_api.py +++ b/odes_storage/api/records_api.py @@ -29,7 +29,9 @@ class _RecordsApi: headers = {"data-partition-id": str(data_partition_id)} - body = jsonable_encoder(record) + #Warning this part is edited manually, keeping unset values breaks the storage service + #POST new data seems ok but when getting them storage 500 if for instance we push createTime with a null value + body = jsonable_encoder(record, exclude_unset=True) return self.api_client.request( type_=m.CreateUpdateRecordsResponse, diff --git a/odes_storage/docs/Record.md b/odes_storage/docs/Record.md index aea2fb9bc5a480e843673abad0149346372b8923..43241cb566e23cea5e8321d568cfc44fa7015b6d 100644 --- a/odes_storage/docs/Record.md +++ b/odes_storage/docs/Record.md @@ -11,6 +11,11 @@ Name | Type | Description | Notes **meta** | **List[dict]** | | [optional] **data** | [**dict(str, Any)**](Any.md) | Record payload represented as a list of key-value pairs. | **ancestry** | [**RecordAncestry**](RecordAncestry.md) | | [optional] +**tags** | **dict(str, str)** | A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values. | [optional] +**create_time** | **datetime** | Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC. | [optional] +**create_user** | **str** | The user reference, which created the first version of this resource object. Set by the System. | [optional] +**modify_time** | **datetime** | Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC. | [optional] +**modify_user** | **str** | The user reference, which created this version of this resource object. Set by the System. | [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) diff --git a/odes_storage/models.py b/odes_storage/models.py index 3c0baf4ca0d909dc28ac26f59937eb1178903b5a..86021af847031cafcc4a757cf704c3b20922c515 100644 --- a/odes_storage/models.py +++ b/odes_storage/models.py @@ -1,3 +1,4 @@ +from datetime import datetime from typing import Any # noqa from typing import Dict, List, Optional @@ -30,9 +31,7 @@ class DatastoreQueryResult(BaseModel): class Legal(BaseModel): legaltags: "Optional[List[str]]" = Field(None, alias="legaltags") - other_relevant_data_countries: "Optional[List[str]]" = Field( - None, alias="otherRelevantDataCountries" - ) + other_relevant_data_countries: "Optional[List[str]]" = Field(None, alias="otherRelevantDataCountries") class MultiRecordIds(BaseModel): @@ -53,9 +52,7 @@ class MultiRecordRequest(BaseModel): class MultiRecordResponse(BaseModel): records: "Optional[List[str]]" = Field(None, alias="records") not_found: "Optional[List[str]]" = Field(None, alias="notFound") - conversion_statuses: "Optional[List[ConversionStatus]]" = Field( - None, alias="conversionStatuses" - ) + conversion_statuses: "Optional[List[ConversionStatus]]" = Field(None, alias="conversionStatuses") class Record(BaseModel): @@ -67,6 +64,11 @@ class Record(BaseModel): meta: "Optional[List[Dict[str, Any]]]" = Field(None, alias="meta") data: "Dict[str, Any]" = Field(..., alias="data") ancestry: "Optional[RecordAncestry]" = Field(None, alias="ancestry") + tags: "Optional[Dict[str, str]]" = Field(None, alias="tags") + create_time: "Optional[datetime]" = Field(None, alias="createTime") + create_user: "Optional[str]" = Field(None, alias="createUser") + modify_time: "Optional[datetime]" = Field(None, alias="modifyTime") + modify_user: "Optional[str]" = Field(None, alias="modifyUser") class RecordAncestry(BaseModel): diff --git a/openapi-storage.yaml b/openapi-storage.yaml index 1b610b602a07cf80fd7d6177ae3be83c84bc5fcc..4258e6911af9fcda0f207dc82391361c73722af5 100644 --- a/openapi-storage.yaml +++ b/openapi-storage.yaml @@ -833,6 +833,43 @@ components: type: object ancestry: $ref: "#/components/schemas/RecordAncestry" + tags: + title: Tag Dictionary + description: A generic dictionary of string keys mapping to string value. Only + strings are permitted as keys and values. + type: object + additionalProperties: + type: string + example: + NameOfKey: String value + createTime: + description: Timestamp of the time at which initial version of this OSDU + resource object was created. Set by the System. The value is a + combined date-time string in ISO-8601 given in UTC. + title: Resource Object Creation DateTime + type: string + format: date-time + example: 2020-12-16T11:46:20.163Z + createUser: + title: Resource Object Creation User Reference + description: The user reference, which created the first version of this + resource object. Set by the System. + type: string + example: some-user@some-company-cloud.com + modifyTime: + description: Timestamp of the time at which this version of the OSDU resource + object was created. Set by the System. The value is a combined + date-time string in ISO-8601 given in UTC. + title: Resource Object Version Creation DateTime + type: string + format: date-time + example: 2020-12-16T11:52:24.477Z + modifyUser: + title: Resource Object Version Creation User Reference + description: The user reference, which created this version of this resource + object. Set by the System. + type: string + example: some-user@some-company-cloud.com description: Storage record example: - id: common:welldb:123456 diff --git a/setup.py b/setup.py index cf1871cd4b571bb4034607db04559c6b12934b24..3f5b51620e4085da5fe6a57c6d7bdb1b7f8ac41c 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ with open("README.md", "r") as fh: long_description = fh.read() NAME = "osdu-data-ecosystem-storage" -VERSION = "1.0.0" +VERSION = "1.1.0" # To install the library, run the following # # python setup.py install diff --git a/test/exception_test.py b/test/exception_test.py index a8420c959868051f64537a6f8bdbb12d9ec9fc02..e31f97ca43912053d24db199d104c4fe52f46c3d 100644 --- a/test/exception_test.py +++ b/test/exception_test.py @@ -28,6 +28,11 @@ valid_record = { }, "data": {"msg": "hello world"}, "meta": [{"kind": "Unit", "persistableReference": "ref"}], + "tags": {'NameOfKey': 'String value', 'OtherKey': 'Other value'}, + "createTime": "2021-02-11T17:01:23.214000+00:00", + "createUser": "me@slb.com", + "modifyTime": "2021-02-23T14:53:08.758000+00:00", + "modifyUser": "ze@slb.com" } invalid_record = {}