diff --git a/README.md b/README.md index ff7f16c..50cd14d 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ OSDUAPI.print_available_services() ``` ```bash -| Name | versions | +| Name | Versions | =================================== | dataset | latest | | entitlements | latest | diff --git a/gen/client_generator.py b/gen/client_generator.py index c6bf234..a0d02cd 100644 --- a/gen/client_generator.py +++ b/gen/client_generator.py @@ -8,8 +8,6 @@ from .helpers import get_path, get_server_url, load_swagger from .swagger import SwaggerDoc -import xml.etree.ElementTree as ET - BASE_DIR = os.path.dirname(__file__) @@ -87,6 +85,8 @@ def get_type_for_param(param: dict, swagger: dict | None = None) -> str: types.append( COMPLEX_TYPES_MAP[(_type, items_type)] ) + if len(types) == 1: + return types[0] return "Union[%s]" % ", ".join(types) while ref_path or all_of: @@ -327,12 +327,8 @@ def get_name_from_name_map(method: str, path: str, method_names_file: str): def create_method_name(method: str, path: str, name_parts: list[str], swagger: dict, method_names_file: str) -> str: - # try: summary = swagger["paths"][path][method].get("summary") description = swagger["paths"][path][method].get("description", "") - # except TypeError as e: - # print(name_parts, path) - # raise e name = get_name_from_name_map(method, path, method_names_file) if name: @@ -562,24 +558,23 @@ def create_method_sig(swagger: dict, name: str, params: list[str], body_required ] elements = [name, ] sig = "" - _input_parameters_strings = [] - - - _input_parameters_strings += [param_to_function_argument(p) - for p in sorted(path_params, key=lambda x: 0 if x.get("required") else 1)] - if body_not_required: - _input_parameters_strings += parse_request_body(swagger, body_not_required) + _input_parameters_strings = [param_to_function_argument(p) + for p in path_params] if body_required: _input_parameters_strings += parse_request_body(swagger, body_required) + if body_not_required: + _input_parameters_strings += parse_request_body(swagger, body_not_required) + if _input_parameters_strings: sig += ", ".join(_input_parameters_strings) if sig: elements.append(sig) - doc = generate_doc_string(name, path_params, body_required, body_not_required, swagger, method, path, indent_offset=1) + doc = generate_doc_string(name, path_params, body_required, body_not_required, + swagger, method, path, indent_offset=1) try: if len(elements) > 1: sig = "def %s(self, *, %s, data_partition_id: str | None = None) -> dict:" % tuple(elements) diff --git a/gen/helpers.py b/gen/helpers.py index 9c58ee9..a592971 100644 --- a/gen/helpers.py +++ b/gen/helpers.py @@ -1,7 +1,7 @@ import json import os -import sys import re +import sys from subprocess import PIPE, Popen from typing import Any diff --git a/osdu_client/client.py b/osdu_client/client.py index d4810f9..609225d 100644 --- a/osdu_client/client.py +++ b/osdu_client/client.py @@ -59,7 +59,10 @@ def client(service_name, auth_backend: AuthBackendInterface, version: str | None @classmethod def print_available_services(cls): - print("| Name | versions |") + """ + Prints available services for client + """ + print("| Name | Versions |") print("===================================") for k, v in cls.list_available_services(): print("|", end="") @@ -73,6 +76,11 @@ def print_available_services(cls): print("|") @staticmethod - def list_available_services() -> list[str, list[str]]: + def list_available_services() -> list[tuple[str, list[str]]]: + """ + Returns list of available services for client + Returns: + list of available services for API versions (list[tuple[str, list[str]]]) + """ module = import_module("osdu_client.services") return [(k, v) for k, v in module.SERVICES.items()] diff --git a/osdu_client/services/__init__.py b/osdu_client/services/__init__.py index ab5f3e7..8c912ea 100644 --- a/osdu_client/services/__init__.py +++ b/osdu_client/services/__init__.py @@ -1,4 +1,4 @@ -from osdu_client.services import (rafs, wellbore) +from osdu_client.services import rafs, wellbore SERVICES = { "dataset": [], diff --git a/osdu_client/services/file/client.py b/osdu_client/services/file/client.py index e03eda2..e55def3 100644 --- a/osdu_client/services/file/client.py +++ b/osdu_client/services/file/client.py @@ -7,7 +7,7 @@ from osdu_client.utils import urljoin from osdu_client.validation import validate_data -from .models import DeliveryGetFileSignedURLRequest, FileListRequest, FileLocationRequest, LocationRequest, Record +from .models import FileListRequest, FileLocationRequest, LocationRequest, Record, DeliveryGetFileSignedURLRequest class FileAPIError(OSDUAPIError): @@ -81,12 +81,12 @@ def get_files_upload_url(self, data_partition_id: str | None = None) -> dict: def create_files_metadata( self, *, - id: str | None = None, - ancestry: dict | None = None, kind: str, acl: dict, legal: dict, data: dict, + id: str | None = None, + ancestry: dict | None = None, data_partition_id: str | None = None, ) -> dict: """ diff --git a/osdu_client/services/indexer/client.py b/osdu_client/services/indexer/client.py index ad6e4e2..9bd0523 100644 --- a/osdu_client/services/indexer/client.py +++ b/osdu_client/services/indexer/client.py @@ -42,8 +42,8 @@ def reindex_kind( self, *, force_clean: str | None = None, - cursor: str | None = None, kind: str, + cursor: str | None = None, data_partition_id: str | None = None, ) -> dict: """ diff --git a/osdu_client/services/sdms/client.py b/osdu_client/services/sdms/client.py index ab9dec9..c0a50e7 100644 --- a/osdu_client/services/sdms/client.py +++ b/osdu_client/services/sdms/client.py @@ -85,12 +85,12 @@ def get_info(self, data_partition_id: str | None = None) -> dict: def register_new_dataset( self, *, - tenantid: str, - subprojectid: str, - datasetid: str, impersonation_token_context: str | None = None, ltag: str | None = None, + tenantid: str, + subprojectid: str, path: str | None = None, + datasetid: str, type: str | None = None, gtags: list[str] | None = None, seismicmeta: dict | None = None, @@ -164,11 +164,11 @@ def register_new_dataset( def get_dataset( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, - datasetid: str, - impersonation_token_context: str | None = None, path: str | None = None, + datasetid: str, seismicmeta: str | None = None, translate_user_info: str | None = None, record_version: str | None = None, @@ -222,11 +222,11 @@ def get_dataset( def delete_dataset( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, - datasetid: str, - impersonation_token_context: str | None = None, path: str | None = None, + datasetid: str, data_partition_id: str | None = None, ) -> dict: """ @@ -268,11 +268,11 @@ def delete_dataset( def patch_dataset_metadata( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, - datasetid: str, - impersonation_token_context: str | None = None, path: str | None = None, + datasetid: str, close: str | None = None, dataset_new_name: str | None = None, metadata: dict | None = None, @@ -391,11 +391,11 @@ def patch_dataset_metadata( def acquire_lock_for_dataset( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, - datasetid: str, - impersonation_token_context: str | None = None, path: str | None = None, + datasetid: str, openmode: str | None = None, wid: str | None = None, data_partition_id: str | None = None, @@ -461,11 +461,11 @@ def acquire_lock_for_dataset( def remove_lock_associated_with_dataset( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, - datasetid: str, - impersonation_token_context: str | None = None, path: str | None = None, + datasetid: str, data_partition_id: str | None = None, ) -> dict: """ @@ -516,11 +516,11 @@ def remove_lock_associated_with_dataset( def get_dataset_access_permissions( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, - datasetid: str, - impersonation_token_context: str | None = None, path: str | None = None, + datasetid: str, data_partition_id: str | None = None, ) -> dict: """ @@ -571,12 +571,12 @@ def get_dataset_access_permissions( def validate_ctag( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, + path: str | None = None, datasetid: str, ctag: str, - impersonation_token_context: str | None = None, - path: str | None = None, data_partition_id: str | None = None, ) -> dict: """ @@ -621,12 +621,12 @@ def validate_ctag( def upsert_tags_to_dataset( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, + path: str | None = None, datasetid: str, gtag: str, - impersonation_token_context: str | None = None, - path: str | None = None, data_partition_id: str | None = None, ) -> dict: """ @@ -680,11 +680,11 @@ def upsert_tags_to_dataset( def compute_and_get_size_dataset( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, datasetid: str, path: str, - impersonation_token_context: str | None = None, data_partition_id: str | None = None, ) -> dict: """ @@ -729,9 +729,9 @@ def compute_and_get_size_dataset( def get_datasets_sizes( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, - impersonation_token_context: str | None = None, datasetid: str | None = None, path: str | None = None, data_partition_id: str | None = None, @@ -778,9 +778,9 @@ def get_datasets_sizes( def get_content_list( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, - impersonation_token_context: str | None = None, path: str | None = None, data_partition_id: str | None = None, ) -> dict: @@ -825,9 +825,9 @@ def get_content_list( def list_datasets_in_subproject( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, - impersonation_token_context: str | None = None, translate_user_info: str | None = None, type: str | None = None, gtags: list[str] | None = None, @@ -901,9 +901,9 @@ def list_datasets_in_subproject( def check_datasets_list( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, - impersonation_token_context: str | None = None, datasets: list[str], data_partition_id: str | None = None, ) -> dict: @@ -950,9 +950,9 @@ def check_datasets_list( def list_datasets_sizes( self, *, + impersonation_token_context: str | None = None, tenantid: str, subprojectid: str, - impersonation_token_context: str | None = None, datasets: list[str], data_partition_id: str | None = None, ) -> dict: @@ -1001,8 +1001,8 @@ def list_datasets_sizes( def ls( self, *, - sdpath: str, impersonation_token_context: str | None = None, + sdpath: str, wmode: str | None = None, limit: str | None = None, cursor: str | None = None, @@ -1052,10 +1052,10 @@ def ls_post( self, *, impersonation_token_context: str | None = None, + sdpath: str, wmode: str | None = None, limit: int | None = None, cursor: str | None = None, - sdpath: str, data_partition_id: str | None = None, ) -> dict: """ @@ -1125,9 +1125,9 @@ def list_storage_tiers(self, data_partition_id: str | None = None) -> dict: def copy_dataset( self, *, + impersonation_token_context: str | None = None, sdpath_from: str, sdpath_to: str, - impersonation_token_context: str | None = None, lock: str | None = None, data_partition_id: str | None = None, ) -> dict: @@ -1176,8 +1176,8 @@ def copy_dataset( def get_gcs_access_token( self, *, - sdpath: str, impersonation_token_context: str | None = None, + sdpath: str, readonly: str | None = None, data_partition_id: str | None = None, ) -> dict: @@ -1224,8 +1224,8 @@ def get_gcs_access_token( def get_upload_connection_credential_string( self, *, - sdpath: str, impersonation_token_context: str | None = None, + sdpath: str, data_partition_id: str | None = None, ) -> dict: """ @@ -1261,8 +1261,8 @@ def get_upload_connection_credential_string( def get_download_connection_credentials_string( self, *, - sdpath: str, impersonation_token_context: str | None = None, + sdpath: str, data_partition_id: str | None = None, ) -> dict: """ @@ -1409,8 +1409,8 @@ def create_impersonation_token( self, *, user_token: str, - metadata: dict | None = None, resources: list[dict], + metadata: dict | None = None, data_partition_id: str | None = None, ) -> dict: """ @@ -1488,9 +1488,9 @@ def refresh_impersonation_token( def create_new_subproject( self, *, + ltag: str | None = None, subprojectid: str, tenantid: str, - ltag: str | None = None, admin: str | None = None, storage_class: str | None = None, storage_location: str | None = None, diff --git a/osdu_client/services/search/client.py b/osdu_client/services/search/client.py index e7d90f6..3a3ac55 100644 --- a/osdu_client/services/search/client.py +++ b/osdu_client/services/search/client.py @@ -20,6 +20,7 @@ class SearchClient(OSDUAPIClient): def query_with_cursor( self, *, + kind: dict, limit: int | None = None, query: str | None = None, highlighted_fields: list[str] | None = None, @@ -29,7 +30,6 @@ def query_with_cursor( track_total_count: bool | None = None, spatial_filter: dict | None = None, cursor: str | None = None, - kind: dict, data_partition_id: str | None = None, ) -> dict: """ @@ -92,6 +92,7 @@ def query_with_cursor( def query( self, *, + kind: dict, limit: int | None = None, query: str | None = None, highlighted_fields: list[str] | None = None, @@ -102,7 +103,6 @@ def query( spatial_filter: dict | None = None, aggregate_by: str | None = None, offset: int | None = None, - kind: dict, data_partition_id: str | None = None, ) -> dict: """ diff --git a/osdu_client/services/storage/client.py b/osdu_client/services/storage/client.py index c774de7..33c9982 100644 --- a/osdu_client/services/storage/client.py +++ b/osdu_client/services/storage/client.py @@ -141,8 +141,8 @@ def update_records_copy( def delete_record( self, *, - id: str, x_collaboration: str | None = None, + id: str, data_partition_id: str | None = None, ) -> dict: """ @@ -203,10 +203,10 @@ def create_records_delete( def query_records_from_kind( self, *, - kind: str, x_collaboration: str | None = None, cursor: str | None = None, limit: str | None = None, + kind: str, data_partition_id: str | None = None, ) -> dict: """ @@ -248,8 +248,8 @@ def query_records( self, *, x_collaboration: str | None = None, - attributes: list[str] | None = None, records: list[str], + attributes: list[str] | None = None, data_partition_id: str | None = None, ) -> dict: """ @@ -290,8 +290,8 @@ def query_records( def query_records_batch( self, *, - frame_of_reference: str, x_collaboration: str | None = None, + frame_of_reference: str, records: list[str], data_partition_id: str | None = None, ) -> dict: @@ -336,8 +336,8 @@ def query_records_batch( def get_record( self, *, - id: str, x_collaboration: str | None = None, + id: str, attribute: str | None = None, data_partition_id: str | None = None, ) -> dict: @@ -374,8 +374,8 @@ def get_record( def purge_record( self, *, - id: str, x_collaboration: str | None = None, + id: str, data_partition_id: str | None = None, ) -> dict: """ @@ -407,9 +407,9 @@ def purge_record( def get_record_version( self, *, + x_collaboration: str | None = None, id: str, version: str, - x_collaboration: str | None = None, attribute: str | None = None, data_partition_id: str | None = None, ) -> dict: @@ -447,8 +447,8 @@ def get_record_version( def get_record_versions( self, *, - id: str, x_collaboration: str | None = None, + id: str, data_partition_id: str | None = None, ) -> dict: """ @@ -521,8 +521,8 @@ def get_info(self, data_partition_id: str | None = None) -> dict: def purge_record_versions( self, *, - id: str, x_collaboration: str | None = None, + id: str, version_ids: str | None = None, limit: str | None = None, _form: str | None = None, @@ -592,8 +592,8 @@ def get_replay_status( def create_replay( self, *, - filter: Union[list[str]] | None = None, operation: str, + filter: list[str] | None = None, data_partition_id: str | None = None, ) -> dict: """ @@ -601,7 +601,7 @@ def create_replay( Args: data_partition_id (str): identifier of the data partition to query. If None sets by auth session. operation (str): - filter (Union[list[str]]): + filter (list[str]): Returns: response data (dict) Raises: diff --git a/osdu_client/services/wellbore/common.py b/osdu_client/services/wellbore/common.py index e823b83..87e7d63 100644 --- a/osdu_client/services/wellbore/common.py +++ b/osdu_client/services/wellbore/common.py @@ -41,9 +41,9 @@ def get_about(self, data_partition_id: str | None = None) -> dict: def recognize_family( self, *, + label: str, description: str | None = None, log_unit: str | None = None, - label: str, data_partition_id: str | None = None, ) -> dict: """ diff --git a/osdu_client/services/wellbore/v2.py b/osdu_client/services/wellbore/v2.py index 4c1ef67..3e78135 100644 --- a/osdu_client/services/wellbore/v2.py +++ b/osdu_client/services/wellbore/v2.py @@ -172,10 +172,10 @@ def create_alpha_logs_sessions( self, *, record_id: str, + mode: str, from_version: int | None = 0, meta: dict | None = None, time_to_live: int | None = "1440", - mode: str, data_partition_id: str | None = None, ) -> dict: """ @@ -709,14 +709,14 @@ def update_dip( *, dipsetid: str, index: str, + azimuth: dict, + inclination: dict, + reference: dict, classification: str | None = None, quality: dict | None = None, x_coordinate: dict | None = None, y_coordinate: dict | None = None, z_coordinate: dict | None = None, - azimuth: dict, - inclination: dict, - reference: dict, data_partition_id: str | None = None, ) -> dict: """ diff --git a/osdu_client/services/wellbore/v3.py b/osdu_client/services/wellbore/v3.py index 07f43de..4ceace6 100644 --- a/osdu_client/services/wellbore/v3.py +++ b/osdu_client/services/wellbore/v3.py @@ -827,10 +827,10 @@ def create_wellboretrajectories_sessions( self, *, record_id: str, + mode: str, from_version: int | None = 0, meta: dict | None = None, time_to_live: int | None = "1440", - mode: str, data_partition_id: str | None = None, ) -> dict: """ @@ -1431,10 +1431,10 @@ def create_welllogs_sessions( self, *, record_id: str, + mode: str, from_version: int | None = 0, meta: dict | None = None, time_to_live: int | None = "1440", - mode: str, data_partition_id: str | None = None, ) -> dict: """ diff --git a/pyproject.toml b/pyproject.toml index d7565a7..182818d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "osdu-client" -version = "1.1.0" +version = "1.2.0" description = "OSDU API Client" authors = ["Michal Murawski "] readme = "README.md"