diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9c18110 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 349ef78..b8d3f61 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ __pycache__ build dist docs/_build +.DS_Store +.pytest_cache # PyCharm files *.iml diff --git a/.pytest_cache/README.md b/.pytest_cache/README.md new file mode 100644 index 0000000..bb78ba0 --- /dev/null +++ b/.pytest_cache/README.md @@ -0,0 +1,8 @@ +# pytest cache directory # + +This directory contains data from the pytest's cache plugin, +which provides the `--lf` and `--ff` options, as well as the `cache` fixture. + +**Do not** commit this to version control. + +See [the docs](https://docs.pytest.org/en/latest/cache.html) for more information. diff --git a/.pytest_cache/v/cache/lastfailed b/.pytest_cache/v/cache/lastfailed new file mode 100644 index 0000000..af8cef0 --- /dev/null +++ b/.pytest_cache/v/cache/lastfailed @@ -0,0 +1,14 @@ +{ + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_create_project": true, + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_get_project[simple_key]": true, + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_get_project[url]": true, + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_update_project[simple_key]": true, + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_update_project[url]": true, + "tests/datadotworld/models/test_dataset.py::TestLocalDataset::()::test_tables": true, + "tests/datadotworld/models/test_project.py::MyTest::test": true, + "tests/datadotworld/models/test_project.py::MyTest::test_create_project": true, + "tests/datadotworld/models/test_project.py::MyTest::test_get_project": true, + "tests/datadotworld/models/test_project.py::MyTest::test_toplevel_get_project": true, + "tests/datadotworld/models/test_project.py::MyTest::test_valid_get_project": true, + "tests/datadotworld/models/test_project.py::TestProjects::test_create_project": true +} \ No newline at end of file diff --git a/.pytest_cache/v/cache/nodeids b/.pytest_cache/v/cache/nodeids new file mode 100644 index 0000000..3c40953 --- /dev/null +++ b/.pytest_cache/v/cache/nodeids @@ -0,0 +1,182 @@ +[ + "tests/datadotworld/test_cli.py::test_configure", + "tests/datadotworld/test_config.py::TestDefaultConfig::()::test_auth_token", + "tests/datadotworld/test_config.py::TestDefaultConfig::()::test_cache_dir", + "tests/datadotworld/test_config.py::TestDefaultConfig::()::test_tmp_dir", + "tests/datadotworld/test_config.py::TestInlineConfig::()::test_auth_token", + "tests/datadotworld/test_config.py::TestInlineConfig::()::test_cache_dir", + "tests/datadotworld/test_config.py::TestInlineConfig::()::test_tmp_dir", + "tests/datadotworld/test_config.py::TestEnvConfig::()::test_auth_token", + "tests/datadotworld/test_config.py::TestEnvConfig::()::test_cache_dir", + "tests/datadotworld/test_config.py::TestEnvConfig::()::test_tmp_dir", + "tests/datadotworld/test_config.py::TestFileConfig::()::test_auth_token", + "tests/datadotworld/test_config.py::TestFileConfig::()::test_alternative_token", + "tests/datadotworld/test_config.py::TestFileConfig::()::test_legacy_token", + "tests/datadotworld/test_config.py::TestFileConfig::()::test_invalid_config_section", + "tests/datadotworld/test_config.py::TestFileConfig::()::test_missing_file", + "tests/datadotworld/test_config.py::TestFileConfig::()::test_missing_file_unsuitable_legacy_file", + "tests/datadotworld/test_config.py::TestFileConfig::()::test_missing_token", + "tests/datadotworld/test_config.py::TestFileConfig::()::test_save", + "tests/datadotworld/test_config.py::TestFileConfig::()::test_save_overwrite", + "tests/datadotworld/test_config.py::TestChainedConfig::()::test_auth_token", + "tests/datadotworld/test_config.py::TestChainedConfig::()::test_cache_dir", + "tests/datadotworld/test_config.py::TestChainedConfig::()::test_tmp_dir", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_query[simple_key-sparql]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_query[simple_key-sql]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_query[url-sparql]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_query[url-sql]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_query_400[simple_key-sparql]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_query_400[simple_key-sql]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_query_400[url-sparql]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_query_400[url-sql]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_parameterized_queries[simple_key-sql-notreallysql-parameters0-expected0]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_parameterized_queries[simple_key-sparql-notreallysparql-parameters1-expected1]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_parameterized_queries[url-sql-notreallysql-parameters0-expected0]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_parameterized_queries[url-sparql-notreallysparql-parameters1-expected1]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset[simple_key]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset[url]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_open_file_writer[simple_key]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_open_file_writer[url]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset_existing[simple_key]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset_existing[url]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset_existing_expired[simple_key]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset_existing_expired[url]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset_existing_forced[simple_key]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset_existing_forced[url]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset_forced_fallback[simple_key]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset_forced_fallback[url]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset_existing_expired_auto_update[simple_key]", + "tests/datadotworld/test_datadotworld.py::TestDataDotWorld::()::test_load_dataset_existing_expired_auto_update[url]", + "tests/datadotworld/test_datadotworld.py::test_toplevel_load_dataset[default]", + "tests/datadotworld/test_datadotworld.py::test_toplevel_load_dataset[alternative]", + "tests/datadotworld/test_datadotworld.py::test_toplevel_query[default]", + "tests/datadotworld/test_datadotworld.py::test_toplevel_query[alternative]", + "tests/datadotworld/test_datadotworld.py::test_toplevel_api_client[default]", + "tests/datadotworld/test_datadotworld.py::test_toplevel_api_client[alternative]", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_write_basic", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_write_csv", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_write_error", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_write_timeout_error", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_read_basic", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_read_non_utf_8", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_read_binary_basic", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_read_binary_bytes", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_read_binary_iter", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_read_binary_iter_chunks", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_read_binary_bytes_iter", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_read_error", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_read_csv", + "tests/datadotworld/test_files.py::TestDataDotWorldFileWriter::()::test_read_jsonl", + "tests/datadotworld/test_util.py::test_parse_dataset_key", + "tests/datadotworld/test_util.py::test_parse_dataset_key_with_url", + "tests/datadotworld/test_util.py::test_parse_dataset_key_with_bad_path", + "tests/datadotworld/test_util.py::test_parse_dataset_key_with_bad_url", + "tests/datadotworld/test_util.py::test__user_agent", + "tests/datadotworld/test_util.py::TestLazyLoadedDict::()::test_get", + "tests/datadotworld/test_util.py::TestLazyLoadedDict::()::test_get_error", + "tests/datadotworld/test_util.py::TestLazyLoadedDict::()::test_iter", + "tests/datadotworld/test_util.py::TestLazyLoadedDict::()::test_repr", + "tests/datadotworld/test_util.py::TestLazyLoadedDict::()::test_str", + "tests/datadotworld/test_util.py::TestLazyLoadedValue::()::test_call", + "tests/datadotworld/test_util.py::TestLazyLoadedValue::()::test_repr", + "tests/datadotworld/test_util.py::TestLazyLoadedValue::()::test_str", + "tests/datadotworld/test_util.py::TestMemoized::()::test_memoized", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_get_dataset[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_get_dataset[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_create_dataset", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_update_dataset[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_update_dataset[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_replace_dataset[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_replace_dataset[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_delete_dataset[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_delete_dataset[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_add_files_via_url[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_add_files_via_url[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_sync_files[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_sync_files[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_upload_files[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_upload_files[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_upload_file[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_upload_file[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_delete_files[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_delete_files[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_rest_api_error", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_download_datapackage[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_download_datapackage[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_download_datapackage_error[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_download_datapackage_error[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_download_datapackage_existing_dest_dir[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_download_datapackage_existing_dest_dir[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_download_dataset[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_download_dataset[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_download_file[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_download_file[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_sql[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_sql[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_sparql[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_sparql[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_get_user_data", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_fetch_liked_datasets", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_fetch_contributing_datasets", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_fetch_datasets", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_fetch_contributing_projects", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_fetch_liked_projects", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_fetch_projects", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_append_records[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_append_records[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_get_project[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_get_project[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_create_project", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_update_project[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_update_project[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_replace_project[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_replace_project[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_add_linked_dataset[simple_key-simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_add_linked_dataset[simple_key-url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_add_linked_dataset[url-simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_add_linked_dataset[url-url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_remove_linked_dataset[simple_key-simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_remove_linked_dataset[simple_key-url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_remove_linked_dataset[url-simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_remove_linked_dataset[url-url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_delete_project[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_delete_project[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_get_insight[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_get_insight[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_get_insight_for_project[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_get_insight_for_project[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_create_insight[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_create_insight[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_replace_insight[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_replace_insight[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_update_insight[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_update_insight[url]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_delete_insight[simple_key]", + "tests/datadotworld/client/test_client.py::TestApiClient::()::test_delete_insight[url]", + "tests/datadotworld/models/test_dataset.py::TestLocalDataset::()::test_describe", + "tests/datadotworld/models/test_dataset.py::TestLocalDataset::()::test_describe_resource", + "tests/datadotworld/models/test_dataset.py::TestLocalDataset::()::test_raw_data", + "tests/datadotworld/models/test_dataset.py::TestLocalDataset::()::test_tables", + "tests/datadotworld/models/test_dataset.py::TestLocalDataset::()::test_tables_broken_schema", + "tests/datadotworld/models/test_dataset.py::TestLocalDataset::()::test_dataframes", + "tests/datadotworld/models/test_dataset.py::TestLocalDataset::()::test_dataframe_types", + "tests/datadotworld/models/test_dataset.py::TestLocalDataset::()::test_dataframe_broken_schema", + "tests/datadotworld/models/test_dataset.py::TestLocalDataset::()::test_repr", + "tests/datadotworld/models/test_project.py::TestProjects::test_create_project", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_describe[sql_select]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_raw_data[sql_select]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_table[sql_select]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_table_parameterized[sparql_ask]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_table_parameterized[sparql_construct]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_table_parameterized[sparql_construct_mixed_types]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_table_parameterized[sparql_describe]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_table_parameterized[sparql_select]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_table_parameterized[sparql_select_hof]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_table_parameterized[sql_select]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_table_parameterized[sql_select2]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_table_parameterized[sql_select_empty]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_dataframe[sql_select]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_dataframe[sql_select_missing_value]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_str_column[sql_select]", + "tests/datadotworld/models/test_query.py::TestQueryResults::()::test_str[sql_select]" +] \ No newline at end of file diff --git a/Makefile b/Makefile index 7acae27..04367b2 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,3 @@ test: coverage run setup.py test test-report: coverage report -m -update_swagger_codegen: - pushd datadotworld/client; \ - curl https://api.data.world/v0/swagger.json -o swagger-dwapi-def.json; \ - swagger-codegen generate -l python --git-repo-id=data.world-py --git-user-id=datadotworld \ - --http-user-agent="data.world-py" --invoker-package=client \ - -i swagger-dwapi-def.json -c swagger-codegen-config.json --release-note=""; \ - popd; diff --git a/datadotworld/__init__.py b/datadotworld/__init__.py index 228d3e6..f189334 100644 --- a/datadotworld/__init__.py +++ b/datadotworld/__init__.py @@ -55,8 +55,8 @@ def _get_instance(profile, **kwargs): InlineConfig(kwargs.get('auth_token')), EnvConfig(), FileConfig()]) - if profile == 'default' - else FileConfig(profile=profile)) + if profile == 'default' + else FileConfig(profile=profile)) instance = DataDotWorld(config=config_param) __instances[profile] = instance return instance @@ -243,7 +243,7 @@ def api_client(profile='default', **kwargs): ... 'jonloyens/an-intro-to-dataworld-dataset').get('title') 'An Intro to data.world Dataset' """ - return _get_instance(profile, **kwargs).api_client + return _get_instance(profile, **kwargs).api_client.ApiClient if __name__ == "__main__": diff --git a/datadotworld/client/.DS_Store b/datadotworld/client/.DS_Store new file mode 100644 index 0000000..df1d634 Binary files /dev/null and b/datadotworld/client/.DS_Store differ diff --git a/datadotworld/client/.swagger-codegen-ignore b/datadotworld/client/.swagger-codegen-ignore deleted file mode 100644 index 760c2bd..0000000 --- a/datadotworld/client/.swagger-codegen-ignore +++ /dev/null @@ -1,25 +0,0 @@ -# data.world-py -# Copyright 2017 data.world, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the -# License. -# -# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. See the License for the specific language governing -# permissions and limitations under the License. -# -# This product includes software developed at data.world, Inc.(http://www.data.world/). - -# All we want is the actual _rest subpackage, discarding everything else from: -# swagger-codegen generate -l python --git-repo-id=data.world-py --git-user-id=datadotworld \ -# --http-user-agent="data.world-py" --invoker-package=client \ -# -i swagger-dwapi-def.json -c swagger-codegen-config.json --release-note="" -# - -** -!_swagger/** \ No newline at end of file diff --git a/datadotworld/client/.swagger-codegen/VERSION b/datadotworld/client/.swagger-codegen/VERSION deleted file mode 100644 index 6b4d157..0000000 --- a/datadotworld/client/.swagger-codegen/VERSION +++ /dev/null @@ -1 +0,0 @@ -2.2.3 \ No newline at end of file diff --git a/datadotworld/client/_swagger/__init__.py b/datadotworld/client/_swagger/__init__.py deleted file mode 100644 index 70cfff6..0000000 --- a/datadotworld/client/_swagger/__init__.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -# import models into sdk package -from .models.create_dataset_response import CreateDatasetResponse -from .models.create_insight_response import CreateInsightResponse -from .models.create_project_response import CreateProjectResponse -from .models.dataset_create_request import DatasetCreateRequest -from .models.dataset_patch_request import DatasetPatchRequest -from .models.dataset_put_request import DatasetPutRequest -from .models.dataset_summary_response import DatasetSummaryResponse -from .models.error_message import ErrorMessage -from .models.file_batch_update_request import FileBatchUpdateRequest -from .models.file_create_or_update_request import FileCreateOrUpdateRequest -from .models.file_create_request import FileCreateRequest -from .models.file_source_create_or_update_request import FileSourceCreateOrUpdateRequest -from .models.file_source_create_request import FileSourceCreateRequest -from .models.file_source_summary_response import FileSourceSummaryResponse -from .models.file_summary_response import FileSummaryResponse -from .models.insight_body import InsightBody -from .models.insight_create_request import InsightCreateRequest -from .models.insight_patch_request import InsightPatchRequest -from .models.insight_put_request import InsightPutRequest -from .models.insight_summary_response import InsightSummaryResponse -from .models.linked_dataset_create_or_update_request import LinkedDatasetCreateOrUpdateRequest -from .models.linked_dataset_summary_response import LinkedDatasetSummaryResponse -from .models.oauth_token_reference import OauthTokenReference -from .models.paginated_dataset_results import PaginatedDatasetResults -from .models.paginated_insight_results import PaginatedInsightResults -from .models.paginated_project_results import PaginatedProjectResults -from .models.project_create_request import ProjectCreateRequest -from .models.project_patch_request import ProjectPatchRequest -from .models.project_summary_response import ProjectSummaryResponse -from .models.success_message import SuccessMessage -from .models.user_data_response import UserDataResponse -from .models.web_authorization import WebAuthorization -from .models.web_credentials import WebCredentials - -# import apis into sdk package -from .apis.datasets_api import DatasetsApi -from .apis.download_api import DownloadApi -from .apis.insights_api import InsightsApi -from .apis.projects_api import ProjectsApi -from .apis.sparql_api import SparqlApi -from .apis.sql_api import SqlApi -from .apis.streams_api import StreamsApi -from .apis.uploads_api import UploadsApi -from .apis.user_api import UserApi - -# import ApiClient -from .api_client import ApiClient - -from .configuration import Configuration - -configuration = Configuration() diff --git a/datadotworld/client/_swagger/api_client.py b/datadotworld/client/_swagger/api_client.py deleted file mode 100644 index 93eff8a..0000000 --- a/datadotworld/client/_swagger/api_client.py +++ /dev/null @@ -1,633 +0,0 @@ -# coding: utf-8 -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -from __future__ import absolute_import - -import os -import re -import json -import mimetypes -import tempfile -import threading - -from datetime import date, datetime - -# python 2 and python 3 compatibility library -from six import PY3, integer_types, iteritems, text_type -from six.moves.urllib.parse import quote - -from . import models -from .configuration import Configuration -from .rest import ApiException, RESTClientObject - - -class ApiClient(object): - """ - Generic API client for Swagger client library builds. - - Swagger generic API client. This client handles the client- - server communication, and is invariant across implementations. Specifics of - the methods and models for each application are generated from the Swagger - templates. - - NOTE: This class is auto generated by the swagger code generator program. - Ref: https://github.com/swagger-api/swagger-codegen - Do not edit the class manually. - - :param host: The base path for the server to call. - :param header_name: a header to pass when making calls to the API. - :param header_value: a header value to pass when making calls to the API. - """ - - PRIMITIVE_TYPES = (float, bool, bytes, text_type) + integer_types - NATIVE_TYPES_MAPPING = { - 'int': int, - 'long': int if PY3 else long, - 'float': float, - 'str': str, - 'bool': bool, - 'date': date, - 'datetime': datetime, - 'object': object, - } - - def __init__(self, host=None, header_name=None, header_value=None, cookie=None): - """ - Constructor of the class. - """ - self.rest_client = RESTClientObject() - self.default_headers = {} - if header_name is not None: - self.default_headers[header_name] = header_value - if host is None: - self.host = Configuration().host - else: - self.host = host - self.cookie = cookie - # Set default User-Agent. - self.user_agent = 'data.world-py' - - @property - def user_agent(self): - """ - Gets user agent. - """ - return self.default_headers['User-Agent'] - - @user_agent.setter - def user_agent(self, value): - """ - Sets user agent. - """ - self.default_headers['User-Agent'] = value - - def set_default_header(self, header_name, header_value): - self.default_headers[header_name] = header_value - - def __call_api(self, resource_path, method, - path_params=None, query_params=None, header_params=None, - body=None, post_params=None, files=None, - response_type=None, auth_settings=None, callback=None, - _return_http_data_only=None, collection_formats=None, _preload_content=True, - _request_timeout=None): - - config = Configuration() - - # header parameters - header_params = header_params or {} - header_params.update(self.default_headers) - if self.cookie: - header_params['Cookie'] = self.cookie - if header_params: - header_params = self.sanitize_for_serialization(header_params) - header_params = dict(self.parameters_to_tuples(header_params, - collection_formats)) - - # path parameters - if path_params: - path_params = self.sanitize_for_serialization(path_params) - path_params = self.parameters_to_tuples(path_params, - collection_formats) - for k, v in path_params: - # specified safe chars, encode everything - resource_path = resource_path.replace( - '{%s}' % k, quote(str(v), safe=config.safe_chars_for_path_param)) - - # query parameters - if query_params: - query_params = self.sanitize_for_serialization(query_params) - query_params = self.parameters_to_tuples(query_params, - collection_formats) - - # post parameters - if post_params or files: - post_params = self.prepare_post_parameters(post_params, files) - post_params = self.sanitize_for_serialization(post_params) - post_params = self.parameters_to_tuples(post_params, - collection_formats) - - # auth setting - self.update_params_for_auth(header_params, query_params, auth_settings) - - # body - if body: - body = self.sanitize_for_serialization(body) - - # request url - url = self.host + resource_path - - # perform request and return response - response_data = self.request(method, url, - query_params=query_params, - headers=header_params, - post_params=post_params, body=body, - _preload_content=_preload_content, - _request_timeout=_request_timeout) - - self.last_response = response_data - - return_data = response_data - if _preload_content: - # deserialize response data - if response_type: - return_data = self.deserialize(response_data, response_type) - else: - return_data = None - - if callback: - if _return_http_data_only: - callback(return_data) - else: - callback((return_data, response_data.status, response_data.getheaders())) - elif _return_http_data_only: - return (return_data) - else: - return (return_data, response_data.status, response_data.getheaders()) - - def sanitize_for_serialization(self, obj): - """ - Builds a JSON POST object. - - If obj is None, return None. - If obj is str, int, long, float, bool, return directly. - If obj is datetime.datetime, datetime.date - convert to string in iso8601 format. - If obj is list, sanitize each element in the list. - If obj is dict, return the dict. - If obj is swagger model, return the properties dict. - - :param obj: The data to serialize. - :return: The serialized form of data. - """ - if obj is None: - return None - elif isinstance(obj, self.PRIMITIVE_TYPES): - return obj - elif isinstance(obj, list): - return [self.sanitize_for_serialization(sub_obj) - for sub_obj in obj] - elif isinstance(obj, tuple): - return tuple(self.sanitize_for_serialization(sub_obj) - for sub_obj in obj) - elif isinstance(obj, (datetime, date)): - return obj.isoformat() - - if isinstance(obj, dict): - obj_dict = obj - else: - # Convert model obj to dict except - # attributes `swagger_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) - for attr, _ in iteritems(obj.swagger_types) - if getattr(obj, attr) is not None} - - return {key: self.sanitize_for_serialization(val) - for key, val in iteritems(obj_dict)} - - def deserialize(self, response, response_type): - """ - Deserializes response into an object. - - :param response: RESTResponse object to be deserialized. - :param response_type: class literal for - deserialized object, or string of class name. - - :return: deserialized object. - """ - # handle file downloading - # save response body into a tmp file and return the instance - if response_type == "file": - return self.__deserialize_file(response) - - # fetch data from response object - try: - data = json.loads(response.data) - except ValueError: - data = response.data - - return self.__deserialize(data, response_type) - - def __deserialize(self, data, klass): - """ - Deserializes dict, list, str into an object. - - :param data: dict, list or str. - :param klass: class literal, or string of class name. - - :return: object. - """ - if data is None: - return None - - if type(klass) == str: - if klass.startswith('list['): - sub_kls = re.match('list\[(.*)\]', klass).group(1) - return [self.__deserialize(sub_data, sub_kls) - for sub_data in data] - - if klass.startswith('dict('): - sub_kls = re.match('dict\(([^,]*), (.*)\)', klass).group(2) - return {k: self.__deserialize(v, sub_kls) - for k, v in iteritems(data)} - - # convert str to class - if klass in self.NATIVE_TYPES_MAPPING: - klass = self.NATIVE_TYPES_MAPPING[klass] - else: - klass = getattr(models, klass) - - if klass in self.PRIMITIVE_TYPES: - return self.__deserialize_primitive(data, klass) - elif klass == object: - return self.__deserialize_object(data) - elif klass == date: - return self.__deserialize_date(data) - elif klass == datetime: - return self.__deserialize_datatime(data) - else: - return self.__deserialize_model(data, klass) - - def call_api(self, resource_path, method, - path_params=None, query_params=None, header_params=None, - body=None, post_params=None, files=None, - response_type=None, auth_settings=None, callback=None, - _return_http_data_only=None, collection_formats=None, _preload_content=True, - _request_timeout=None): - """ - Makes the HTTP request (synchronous) and return the deserialized data. - To make an async request, define a function for callback. - - :param resource_path: Path to method endpoint. - :param method: Method to call. - :param path_params: Path parameters in the url. - :param query_params: Query parameters in the url. - :param header_params: Header parameters to be - placed in the request header. - :param body: Request body. - :param post_params dict: Request post form parameters, - for `application/x-www-form-urlencoded`, `multipart/form-data`. - :param auth_settings list: Auth Settings names for the request. - :param response: Response data type. - :param files dict: key -> filename, value -> filepath, - for `multipart/form-data`. - :param callback function: Callback function for asynchronous request. - If provide this parameter, - the request will be called asynchronously. - :param _return_http_data_only: response data without head status code and headers - :param collection_formats: dict of collection formats for path, query, - header, and post parameters. - :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without - reading/decoding response data. Default is True. - :param _request_timeout: timeout setting for this request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) timeouts. - :return: - If provide parameter callback, - the request will be called asynchronously. - The method will return the request thread. - If parameter callback is None, - then the method will return the response directly. - """ - if callback is None: - return self.__call_api(resource_path, method, - path_params, query_params, header_params, - body, post_params, files, - response_type, auth_settings, callback, - _return_http_data_only, collection_formats, _preload_content, _request_timeout) - else: - thread = threading.Thread(target=self.__call_api, - args=(resource_path, method, - path_params, query_params, - header_params, body, - post_params, files, - response_type, auth_settings, - callback, _return_http_data_only, - collection_formats, _preload_content, _request_timeout)) - thread.start() - return thread - - def request(self, method, url, query_params=None, headers=None, - post_params=None, body=None, _preload_content=True, _request_timeout=None): - """ - Makes the HTTP request using RESTClient. - """ - if method == "GET": - return self.rest_client.GET(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) - elif method == "HEAD": - return self.rest_client.HEAD(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) - elif method == "OPTIONS": - return self.rest_client.OPTIONS(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "POST": - return self.rest_client.POST(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "PUT": - return self.rest_client.PUT(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "PATCH": - return self.rest_client.PATCH(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "DELETE": - return self.rest_client.DELETE(url, - query_params=query_params, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - else: - raise ValueError( - "http method must be `GET`, `HEAD`, `OPTIONS`," - " `POST`, `PATCH`, `PUT` or `DELETE`." - ) - - def parameters_to_tuples(self, params, collection_formats): - """ - Get parameters as list of tuples, formatting collections. - - :param params: Parameters as dict or list of two-tuples - :param dict collection_formats: Parameter collection formats - :return: Parameters as list of tuples, collections formatted - """ - new_params = [] - if collection_formats is None: - collection_formats = {} - for k, v in iteritems(params) if isinstance(params, dict) else params: - if k in collection_formats: - collection_format = collection_formats[k] - if collection_format == 'multi': - new_params.extend((k, value) for value in v) - else: - if collection_format == 'ssv': - delimiter = ' ' - elif collection_format == 'tsv': - delimiter = '\t' - elif collection_format == 'pipes': - delimiter = '|' - else: # csv is the default - delimiter = ',' - new_params.append( - (k, delimiter.join(str(value) for value in v))) - else: - new_params.append((k, v)) - return new_params - - def prepare_post_parameters(self, post_params=None, files=None): - """ - Builds form parameters. - - :param post_params: Normal form parameters. - :param files: File parameters. - :return: Form parameters with files. - """ - params = [] - - if post_params: - params = post_params - - if files: - for k, v in iteritems(files): - if not v: - continue - file_names = v if type(v) is list else [v] - for n in file_names: - with open(n, 'rb') as f: - filename = os.path.basename(f.name) - filedata = f.read() - mimetype = mimetypes.\ - guess_type(filename)[0] or 'application/octet-stream' - params.append(tuple([k, tuple([filename, filedata, mimetype])])) - - return params - - def select_header_accept(self, accepts): - """ - Returns `Accept` based on an array of accepts provided. - - :param accepts: List of headers. - :return: Accept (e.g. application/json). - """ - if not accepts: - return - - accepts = [x.lower() for x in accepts] - - if 'application/json' in accepts: - return 'application/json' - else: - return ', '.join(accepts) - - def select_header_content_type(self, content_types): - """ - Returns `Content-Type` based on an array of content_types provided. - - :param content_types: List of content-types. - :return: Content-Type (e.g. application/json). - """ - if not content_types: - return 'application/json' - - content_types = [x.lower() for x in content_types] - - if 'application/json' in content_types or '*/*' in content_types: - return 'application/json' - else: - return content_types[0] - - def update_params_for_auth(self, headers, querys, auth_settings): - """ - Updates header and query params based on authentication setting. - - :param headers: Header parameters dict to be updated. - :param querys: Query parameters tuple list to be updated. - :param auth_settings: Authentication setting identifiers list. - """ - config = Configuration() - - if not auth_settings: - return - - for auth in auth_settings: - auth_setting = config.auth_settings().get(auth) - if auth_setting: - if not auth_setting['value']: - continue - elif auth_setting['in'] == 'header': - headers[auth_setting['key']] = auth_setting['value'] - elif auth_setting['in'] == 'query': - querys.append((auth_setting['key'], auth_setting['value'])) - else: - raise ValueError( - 'Authentication token must be in `query` or `header`' - ) - - def __deserialize_file(self, response): - """ - Saves response body into a file in a temporary folder, - using the filename from the `Content-Disposition` header if provided. - - :param response: RESTResponse. - :return: file path. - """ - config = Configuration() - - fd, path = tempfile.mkstemp(dir=config.temp_folder_path) - os.close(fd) - os.remove(path) - - content_disposition = response.getheader("Content-Disposition") - if content_disposition: - filename = re.\ - search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition).\ - group(1) - path = os.path.join(os.path.dirname(path), filename) - - with open(path, "w") as f: - f.write(response.data) - - return path - - def __deserialize_primitive(self, data, klass): - """ - Deserializes string to primitive type. - - :param data: str. - :param klass: class literal. - - :return: int, long, float, str, bool. - """ - try: - return klass(data) - except UnicodeEncodeError: - return unicode(data) - except TypeError: - return data - - def __deserialize_object(self, value): - """ - Return a original value. - - :return: object. - """ - return value - - def __deserialize_date(self, string): - """ - Deserializes string to date. - - :param string: str. - :return: date. - """ - try: - from dateutil.parser import parse - return parse(string).date() - except ImportError: - return string - except ValueError: - raise ApiException( - status=0, - reason="Failed to parse `{0}` into a date object".format(string) - ) - - def __deserialize_datatime(self, string): - """ - Deserializes string to datetime. - - The string should be in iso8601 datetime format. - - :param string: str. - :return: datetime. - """ - try: - from dateutil.parser import parse - return parse(string) - except ImportError: - return string - except ValueError: - raise ApiException( - status=0, - reason=( - "Failed to parse `{0}` into a datetime object" - .format(string) - ) - ) - - def __deserialize_model(self, data, klass): - """ - Deserializes list or dict to model. - - :param data: dict, list. - :param klass: class literal. - :return: model object. - """ - if not klass.swagger_types: - return data - - kwargs = {} - for attr, attr_type in iteritems(klass.swagger_types): - if data is not None \ - and klass.attribute_map[attr] in data \ - and isinstance(data, (list, dict)): - value = data[klass.attribute_map[attr]] - kwargs[attr] = self.__deserialize(value, attr_type) - - instance = klass(**kwargs) - - return instance diff --git a/datadotworld/client/_swagger/apis/__init__.py b/datadotworld/client/_swagger/apis/__init__.py deleted file mode 100644 index ea67b57..0000000 --- a/datadotworld/client/_swagger/apis/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -from __future__ import absolute_import - -# import apis into api package -from .datasets_api import DatasetsApi -from .download_api import DownloadApi -from .insights_api import InsightsApi -from .projects_api import ProjectsApi -from .sparql_api import SparqlApi -from .sql_api import SqlApi -from .streams_api import StreamsApi -from .uploads_api import UploadsApi -from .user_api import UserApi diff --git a/datadotworld/client/_swagger/apis/datasets_api.py b/datadotworld/client/_swagger/apis/datasets_api.py deleted file mode 100644 index 2483080..0000000 --- a/datadotworld/client/_swagger/apis/datasets_api.py +++ /dev/null @@ -1,1225 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import sys -import os -import re - -# python 2 and python 3 compatibility library -from six import iteritems - -from ..configuration import Configuration -from ..api_client import ApiClient - - -class DatasetsApi(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - Ref: https://github.com/swagger-api/swagger-codegen - """ - - def __init__(self, api_client=None): - config = Configuration() - if api_client: - self.api_client = api_client - else: - if not config.api_client: - config.api_client = ApiClient() - self.api_client = config.api_client - - def add_files_by_source(self, owner, id, body, **kwargs): - """ - Add files - This method allows files published on the web to be added to a data.world dataset via their URL. The source URL will be stored so you can easily update your file anytime it changes via the *fetch latest* link on the [data.world](https://data.world/) dataset page or by triggering the GET:/sync endpoint. Check-out or tutorials for tips on how to add Google Sheets, GitHub and S3 files via URL and how to use webhooks or scripts to keep them always in sync. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.add_files_by_source(owner, id, body, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param FileBatchUpdateRequest body: (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.add_files_by_source_with_http_info(owner, id, body, **kwargs) - else: - (data) = self.add_files_by_source_with_http_info(owner, id, body, **kwargs) - return data - - def add_files_by_source_with_http_info(self, owner, id, body, **kwargs): - """ - Add files - This method allows files published on the web to be added to a data.world dataset via their URL. The source URL will be stored so you can easily update your file anytime it changes via the *fetch latest* link on the [data.world](https://data.world/) dataset page or by triggering the GET:/sync endpoint. Check-out or tutorials for tips on how to add Google Sheets, GitHub and S3 files via URL and how to use webhooks or scripts to keep them always in sync. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.add_files_by_source_with_http_info(owner, id, body, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param FileBatchUpdateRequest body: (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'body'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method add_files_by_source" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `add_files_by_source`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `add_files_by_source`") - # verify the required parameter 'body' is set - if ('body' not in params) or (params['body'] is None): - raise ValueError("Missing the required parameter `body` when calling `add_files_by_source`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `add_files_by_source`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `add_files_by_source`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/datasets/{owner}/{id}/files', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def create_dataset(self, owner, body, **kwargs): - """ - Create a dataset - Create a new dataset. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.create_dataset(owner, body, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param DatasetCreateRequest body: (required) - :return: CreateDatasetResponse - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.create_dataset_with_http_info(owner, body, **kwargs) - else: - (data) = self.create_dataset_with_http_info(owner, body, **kwargs) - return data - - def create_dataset_with_http_info(self, owner, body, **kwargs): - """ - Create a dataset - Create a new dataset. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.create_dataset_with_http_info(owner, body, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param DatasetCreateRequest body: (required) - :return: CreateDatasetResponse - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'body'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method create_dataset" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `create_dataset`") - # verify the required parameter 'body' is set - if ('body' not in params) or (params['body'] is None): - raise ValueError("Missing the required parameter `body` when calling `create_dataset`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `create_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/datasets/{owner}', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='CreateDatasetResponse', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def delete_dataset(self, owner, id, **kwargs): - """ - Delete a dataset - Permanently deletes a dataset and all data associated with it. This operation cannot be undone, although a new dataset may be created with the same id. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_dataset(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.delete_dataset_with_http_info(owner, id, **kwargs) - else: - (data) = self.delete_dataset_with_http_info(owner, id, **kwargs) - return data - - def delete_dataset_with_http_info(self, owner, id, **kwargs): - """ - Delete a dataset - Permanently deletes a dataset and all data associated with it. This operation cannot be undone, although a new dataset may be created with the same id. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_dataset_with_http_info(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_dataset" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `delete_dataset`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `delete_dataset`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `delete_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `delete_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/datasets/{owner}/{id}', 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def delete_file_and_sync_source(self, owner, id, name, **kwargs): - """ - Delete a file - Delete a single file from a dataset by their name, including files added via URL. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_file_and_sync_source(owner, id, name, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str name: Name and unique idenfiier of file within the dataset. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.delete_file_and_sync_source_with_http_info(owner, id, name, **kwargs) - else: - (data) = self.delete_file_and_sync_source_with_http_info(owner, id, name, **kwargs) - return data - - def delete_file_and_sync_source_with_http_info(self, owner, id, name, **kwargs): - """ - Delete a file - Delete a single file from a dataset by their name, including files added via URL. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_file_and_sync_source_with_http_info(owner, id, name, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str name: Name and unique idenfiier of file within the dataset. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'name'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_file_and_sync_source" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `delete_file_and_sync_source`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `delete_file_and_sync_source`") - # verify the required parameter 'name' is set - if ('name' not in params) or (params['name'] is None): - raise ValueError("Missing the required parameter `name` when calling `delete_file_and_sync_source`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `delete_file_and_sync_source`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `delete_file_and_sync_source`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'name' in params and len(params['name']) > 128: - raise ValueError("Invalid value for parameter `name` when calling `delete_file_and_sync_source`, number of items must be less than or equal to `128`") - if 'name' in params and len(params['name']) < 1: - raise ValueError("Invalid value for parameter `name` when calling `delete_file_and_sync_source`, number of items must be greater than or equal to `1`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - if 'name' in params: - path_params['name'] = params['name'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/datasets/{owner}/{id}/files/{name}', 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def delete_files_and_sync_sources(self, owner, id, name, **kwargs): - """ - Delete files - Delete one or more files from a dataset by their name, including files added via URL. **Batching** Note that the `name` parameter can be include multiple times in the query string, once for each file that is to be deleted together in a single request. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_files_and_sync_sources(owner, id, name, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param list[str] name: Names of files to be deleted. Multiple can be provided in a single request by repeating the query string parameter name as many times as necessary. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.delete_files_and_sync_sources_with_http_info(owner, id, name, **kwargs) - else: - (data) = self.delete_files_and_sync_sources_with_http_info(owner, id, name, **kwargs) - return data - - def delete_files_and_sync_sources_with_http_info(self, owner, id, name, **kwargs): - """ - Delete files - Delete one or more files from a dataset by their name, including files added via URL. **Batching** Note that the `name` parameter can be include multiple times in the query string, once for each file that is to be deleted together in a single request. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_files_and_sync_sources_with_http_info(owner, id, name, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param list[str] name: Names of files to be deleted. Multiple can be provided in a single request by repeating the query string parameter name as many times as necessary. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'name'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_files_and_sync_sources" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `delete_files_and_sync_sources`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `delete_files_and_sync_sources`") - # verify the required parameter 'name' is set - if ('name' not in params) or (params['name'] is None): - raise ValueError("Missing the required parameter `name` when calling `delete_files_and_sync_sources`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `delete_files_and_sync_sources`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `delete_files_and_sync_sources`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - if 'name' in params: - query_params.append(('name', params['name'])) - collection_formats['name'] = 'multi' - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/datasets/{owner}/{id}/files', 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def get_dataset(self, owner, id, **kwargs): - """ - Retrieve a dataset - Return details on the dataset. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.get_dataset(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :return: DatasetSummaryResponse - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.get_dataset_with_http_info(owner, id, **kwargs) - else: - (data) = self.get_dataset_with_http_info(owner, id, **kwargs) - return data - - def get_dataset_with_http_info(self, owner, id, **kwargs): - """ - Retrieve a dataset - Return details on the dataset. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.get_dataset_with_http_info(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :return: DatasetSummaryResponse - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_dataset" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `get_dataset`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `get_dataset`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `get_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `get_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/datasets/{owner}/{id}', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='DatasetSummaryResponse', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def patch_dataset(self, owner, id, body, **kwargs): - """ - Update a dataset - Update an existing dataset. Note that only elements or files included in the request will be updated. All omitted elements or files will remain untouched. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.patch_dataset(owner, id, body, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param DatasetPatchRequest body: (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.patch_dataset_with_http_info(owner, id, body, **kwargs) - else: - (data) = self.patch_dataset_with_http_info(owner, id, body, **kwargs) - return data - - def patch_dataset_with_http_info(self, owner, id, body, **kwargs): - """ - Update a dataset - Update an existing dataset. Note that only elements or files included in the request will be updated. All omitted elements or files will remain untouched. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.patch_dataset_with_http_info(owner, id, body, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param DatasetPatchRequest body: (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'body'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method patch_dataset" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `patch_dataset`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `patch_dataset`") - # verify the required parameter 'body' is set - if ('body' not in params) or (params['body'] is None): - raise ValueError("Missing the required parameter `body` when calling `patch_dataset`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `patch_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `patch_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/datasets/{owner}/{id}', 'PATCH', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def replace_dataset(self, owner, id, body, **kwargs): - """ - Create / Replace a dataset - Create a dataset with a given id or completely rewrite the dataset, including any previously added files, if one already exists with the given id. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.replace_dataset(owner, id, body, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param DatasetPutRequest body: (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.replace_dataset_with_http_info(owner, id, body, **kwargs) - else: - (data) = self.replace_dataset_with_http_info(owner, id, body, **kwargs) - return data - - def replace_dataset_with_http_info(self, owner, id, body, **kwargs): - """ - Create / Replace a dataset - Create a dataset with a given id or completely rewrite the dataset, including any previously added files, if one already exists with the given id. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.replace_dataset_with_http_info(owner, id, body, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param DatasetPutRequest body: (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'body'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method replace_dataset" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `replace_dataset`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `replace_dataset`") - # verify the required parameter 'body' is set - if ('body' not in params) or (params['body'] is None): - raise ValueError("Missing the required parameter `body` when calling `replace_dataset`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `replace_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `replace_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/datasets/{owner}/{id}', 'PUT', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def sync(self, owner, id, **kwargs): - """ - Sync files - Update all files within a dataset that have originally been added via URL (e.g. via /datasets endpoints or on data.world). Check-out or tutorials for tips on how to add Google Sheets, GitHub and S3 files via URL and how to use webhooks or scripts to keep them always in sync. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sync(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.sync_with_http_info(owner, id, **kwargs) - else: - (data) = self.sync_with_http_info(owner, id, **kwargs) - return data - - def sync_with_http_info(self, owner, id, **kwargs): - """ - Sync files - Update all files within a dataset that have originally been added via URL (e.g. via /datasets endpoints or on data.world). Check-out or tutorials for tips on how to add Google Sheets, GitHub and S3 files via URL and how to use webhooks or scripts to keep them always in sync. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sync_with_http_info(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method sync" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `sync`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `sync`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `sync`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `sync`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/datasets/{owner}/{id}/sync', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def sync_via_get(self, owner, id, **kwargs): - """ - Sync files (via GET) - Update all files within a dataset that have originally been added via URL (e.g. via /datasets endpoints or on data.world). Check-out or tutorials for tips on how to add Google Sheets, GitHub and S3 files via URL and how to use webhooks or scripts to keep them always in sync. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sync_via_get(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.sync_via_get_with_http_info(owner, id, **kwargs) - else: - (data) = self.sync_via_get_with_http_info(owner, id, **kwargs) - return data - - def sync_via_get_with_http_info(self, owner, id, **kwargs): - """ - Sync files (via GET) - Update all files within a dataset that have originally been added via URL (e.g. via /datasets endpoints or on data.world). Check-out or tutorials for tips on how to add Google Sheets, GitHub and S3 files via URL and how to use webhooks or scripts to keep them always in sync. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sync_via_get_with_http_info(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method sync_via_get" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `sync_via_get`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `sync_via_get`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `sync_via_get`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `sync_via_get`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/datasets/{owner}/{id}/sync', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) diff --git a/datadotworld/client/_swagger/apis/download_api.py b/datadotworld/client/_swagger/apis/download_api.py deleted file mode 100644 index ce34a1d..0000000 --- a/datadotworld/client/_swagger/apis/download_api.py +++ /dev/null @@ -1,270 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import sys -import os -import re - -# python 2 and python 3 compatibility library -from six import iteritems - -from ..configuration import Configuration -from ..api_client import ApiClient - - -class DownloadApi(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - Ref: https://github.com/swagger-api/swagger-codegen - """ - - def __init__(self, api_client=None): - config = Configuration() - if api_client: - self.api_client = api_client - else: - if not config.api_client: - config.api_client = ApiClient() - self.api_client = config.api_client - - def download_dataset(self, owner, id, **kwargs): - """ - Download dataset - This endpoint will return a .zip containing all files within the dataset as originally uploaded. If you are interested retrieving clean data extracted from those files by data.world, check out `GET:/sql` and `GET:/sparql`. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.download_dataset(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :return: None - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.download_dataset_with_http_info(owner, id, **kwargs) - else: - (data) = self.download_dataset_with_http_info(owner, id, **kwargs) - return data - - def download_dataset_with_http_info(self, owner, id, **kwargs): - """ - Download dataset - This endpoint will return a .zip containing all files within the dataset as originally uploaded. If you are interested retrieving clean data extracted from those files by data.world, check out `GET:/sql` and `GET:/sparql`. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.download_dataset_with_http_info(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method download_dataset" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `download_dataset`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `download_dataset`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `download_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `download_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/zip']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/download/{owner}/{id}', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def download_file(self, owner, id, file, **kwargs): - """ - Download file - This endpoint will return a file within the dataset as originally uploaded. If you are interested retrieving clean data extracted from those files by data.world, check out `GET:/sql` and `GET:/sparql`. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.download_file(owner, id, file, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str file: (required) - :return: None - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.download_file_with_http_info(owner, id, file, **kwargs) - else: - (data) = self.download_file_with_http_info(owner, id, file, **kwargs) - return data - - def download_file_with_http_info(self, owner, id, file, **kwargs): - """ - Download file - This endpoint will return a file within the dataset as originally uploaded. If you are interested retrieving clean data extracted from those files by data.world, check out `GET:/sql` and `GET:/sparql`. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.download_file_with_http_info(owner, id, file, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str file: (required) - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'file'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method download_file" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `download_file`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `download_file`") - # verify the required parameter 'file' is set - if ('file' not in params) or (params['file'] is None): - raise ValueError("Missing the required parameter `file` when calling `download_file`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `download_file`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `download_file`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - if 'file' in params: - path_params['file'] = params['file'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/file_download/{owner}/{id}/{file}', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) diff --git a/datadotworld/client/_swagger/apis/insights_api.py b/datadotworld/client/_swagger/apis/insights_api.py deleted file mode 100644 index d5e464e..0000000 --- a/datadotworld/client/_swagger/apis/insights_api.py +++ /dev/null @@ -1,779 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import sys -import os -import re - -# python 2 and python 3 compatibility library -from six import iteritems - -from ..configuration import Configuration -from ..api_client import ApiClient - - -class InsightsApi(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - Ref: https://github.com/swagger-api/swagger-codegen - """ - - def __init__(self, api_client=None): - config = Configuration() - if api_client: - self.api_client = api_client - else: - if not config.api_client: - config.api_client = ApiClient() - self.api_client = config.api_client - - def create_insight(self, project_owner, project_id, **kwargs): - """ - Create an insight - Create a new insight. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.create_insight(project_owner, project_id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param InsightCreateRequest body: - :return: CreateInsightResponse - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.create_insight_with_http_info(project_owner, project_id, **kwargs) - else: - (data) = self.create_insight_with_http_info(project_owner, project_id, **kwargs) - return data - - def create_insight_with_http_info(self, project_owner, project_id, **kwargs): - """ - Create an insight - Create a new insight. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.create_insight_with_http_info(project_owner, project_id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param InsightCreateRequest body: - :return: CreateInsightResponse - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['project_owner', 'project_id', 'body'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method create_insight" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'project_owner' is set - if ('project_owner' not in params) or (params['project_owner'] is None): - raise ValueError("Missing the required parameter `project_owner` when calling `create_insight`") - # verify the required parameter 'project_id' is set - if ('project_id' not in params) or (params['project_id'] is None): - raise ValueError("Missing the required parameter `project_id` when calling `create_insight`") - - if 'project_owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_owner']): - raise ValueError("Invalid value for parameter `project_owner` when calling `create_insight`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'project_id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_id']): - raise ValueError("Invalid value for parameter `project_id` when calling `create_insight`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'project_owner' in params: - path_params['projectOwner'] = params['project_owner'] - if 'project_id' in params: - path_params['projectId'] = params['project_id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/insights/{projectOwner}/{projectId}', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='CreateInsightResponse', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def delete_insight(self, project_owner, project_id, id, **kwargs): - """ - Delete an insight - Delete an existing insight. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_insight(project_owner, project_id, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param str id: Insight unique identifier. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.delete_insight_with_http_info(project_owner, project_id, id, **kwargs) - else: - (data) = self.delete_insight_with_http_info(project_owner, project_id, id, **kwargs) - return data - - def delete_insight_with_http_info(self, project_owner, project_id, id, **kwargs): - """ - Delete an insight - Delete an existing insight. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_insight_with_http_info(project_owner, project_id, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param str id: Insight unique identifier. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['project_owner', 'project_id', 'id'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_insight" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'project_owner' is set - if ('project_owner' not in params) or (params['project_owner'] is None): - raise ValueError("Missing the required parameter `project_owner` when calling `delete_insight`") - # verify the required parameter 'project_id' is set - if ('project_id' not in params) or (params['project_id'] is None): - raise ValueError("Missing the required parameter `project_id` when calling `delete_insight`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `delete_insight`") - - if 'project_owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_owner']): - raise ValueError("Invalid value for parameter `project_owner` when calling `delete_insight`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'project_id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_id']): - raise ValueError("Invalid value for parameter `project_id` when calling `delete_insight`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'project_owner' in params: - path_params['projectOwner'] = params['project_owner'] - if 'project_id' in params: - path_params['projectId'] = params['project_id'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/insights/{projectOwner}/{projectId}/{id}', 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def get_insight(self, project_owner, project_id, id, **kwargs): - """ - Retrieve an insight - Retrieve an insight. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.get_insight(project_owner, project_id, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param str id: Insight unique identifier. (required) - :return: InsightSummaryResponse - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.get_insight_with_http_info(project_owner, project_id, id, **kwargs) - else: - (data) = self.get_insight_with_http_info(project_owner, project_id, id, **kwargs) - return data - - def get_insight_with_http_info(self, project_owner, project_id, id, **kwargs): - """ - Retrieve an insight - Retrieve an insight. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.get_insight_with_http_info(project_owner, project_id, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param str id: Insight unique identifier. (required) - :return: InsightSummaryResponse - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['project_owner', 'project_id', 'id'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_insight" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'project_owner' is set - if ('project_owner' not in params) or (params['project_owner'] is None): - raise ValueError("Missing the required parameter `project_owner` when calling `get_insight`") - # verify the required parameter 'project_id' is set - if ('project_id' not in params) or (params['project_id'] is None): - raise ValueError("Missing the required parameter `project_id` when calling `get_insight`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `get_insight`") - - if 'project_owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_owner']): - raise ValueError("Invalid value for parameter `project_owner` when calling `get_insight`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'project_id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_id']): - raise ValueError("Invalid value for parameter `project_id` when calling `get_insight`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'project_owner' in params: - path_params['projectOwner'] = params['project_owner'] - if 'project_id' in params: - path_params['projectId'] = params['project_id'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/insights/{projectOwner}/{projectId}/{id}', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='InsightSummaryResponse', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def get_insights_for_project(self, project_owner, project_id, **kwargs): - """ - Get insights for project. - Get insights for a project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.get_insights_for_project(project_owner, project_id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param str limit: Maximum number of items to include in a page of results. - :param str next: Token from previous result page to be used when requesting a subsequent page. - :return: PaginatedInsightResults - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.get_insights_for_project_with_http_info(project_owner, project_id, **kwargs) - else: - (data) = self.get_insights_for_project_with_http_info(project_owner, project_id, **kwargs) - return data - - def get_insights_for_project_with_http_info(self, project_owner, project_id, **kwargs): - """ - Get insights for project. - Get insights for a project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.get_insights_for_project_with_http_info(project_owner, project_id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param str limit: Maximum number of items to include in a page of results. - :param str next: Token from previous result page to be used when requesting a subsequent page. - :return: PaginatedInsightResults - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['project_owner', 'project_id', 'limit', 'next'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_insights_for_project" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'project_owner' is set - if ('project_owner' not in params) or (params['project_owner'] is None): - raise ValueError("Missing the required parameter `project_owner` when calling `get_insights_for_project`") - # verify the required parameter 'project_id' is set - if ('project_id' not in params) or (params['project_id'] is None): - raise ValueError("Missing the required parameter `project_id` when calling `get_insights_for_project`") - - if 'project_owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_owner']): - raise ValueError("Invalid value for parameter `project_owner` when calling `get_insights_for_project`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'project_id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_id']): - raise ValueError("Invalid value for parameter `project_id` when calling `get_insights_for_project`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'project_owner' in params: - path_params['projectOwner'] = params['project_owner'] - if 'project_id' in params: - path_params['projectId'] = params['project_id'] - - query_params = [] - if 'limit' in params: - query_params.append(('limit', params['limit'])) - if 'next' in params: - query_params.append(('next', params['next'])) - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/insights/{projectOwner}/{projectId}', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='PaginatedInsightResults', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def replace_insight(self, project_owner, project_id, id, **kwargs): - """ - Replace an insight - Replace an insight. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.replace_insight(project_owner, project_id, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param str id: Insight unique identifier. (required) - :param InsightPutRequest body: - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.replace_insight_with_http_info(project_owner, project_id, id, **kwargs) - else: - (data) = self.replace_insight_with_http_info(project_owner, project_id, id, **kwargs) - return data - - def replace_insight_with_http_info(self, project_owner, project_id, id, **kwargs): - """ - Replace an insight - Replace an insight. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.replace_insight_with_http_info(project_owner, project_id, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param str id: Insight unique identifier. (required) - :param InsightPutRequest body: - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['project_owner', 'project_id', 'id', 'body'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method replace_insight" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'project_owner' is set - if ('project_owner' not in params) or (params['project_owner'] is None): - raise ValueError("Missing the required parameter `project_owner` when calling `replace_insight`") - # verify the required parameter 'project_id' is set - if ('project_id' not in params) or (params['project_id'] is None): - raise ValueError("Missing the required parameter `project_id` when calling `replace_insight`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `replace_insight`") - - if 'project_owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_owner']): - raise ValueError("Invalid value for parameter `project_owner` when calling `replace_insight`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'project_id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_id']): - raise ValueError("Invalid value for parameter `project_id` when calling `replace_insight`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'project_owner' in params: - path_params['projectOwner'] = params['project_owner'] - if 'project_id' in params: - path_params['projectId'] = params['project_id'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/insights/{projectOwner}/{projectId}/{id}', 'PUT', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def update_insight(self, project_owner, project_id, id, **kwargs): - """ - Update an insight - Update an insight. Note that only elements included in the request will be updated. All omitted elements will remain untouched. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.update_insight(project_owner, project_id, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param str id: Insight unique identifier. (required) - :param InsightPatchRequest body: - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.update_insight_with_http_info(project_owner, project_id, id, **kwargs) - else: - (data) = self.update_insight_with_http_info(project_owner, project_id, id, **kwargs) - return data - - def update_insight_with_http_info(self, project_owner, project_id, id, **kwargs): - """ - Update an insight - Update an insight. Note that only elements included in the request will be updated. All omitted elements will remain untouched. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.update_insight_with_http_info(project_owner, project_id, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str project_owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner. (required) - :param str project_id: User name and unique identifier of the project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner. (required) - :param str id: Insight unique identifier. (required) - :param InsightPatchRequest body: - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['project_owner', 'project_id', 'id', 'body'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method update_insight" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'project_owner' is set - if ('project_owner' not in params) or (params['project_owner'] is None): - raise ValueError("Missing the required parameter `project_owner` when calling `update_insight`") - # verify the required parameter 'project_id' is set - if ('project_id' not in params) or (params['project_id'] is None): - raise ValueError("Missing the required parameter `project_id` when calling `update_insight`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `update_insight`") - - if 'project_owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_owner']): - raise ValueError("Invalid value for parameter `project_owner` when calling `update_insight`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'project_id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['project_id']): - raise ValueError("Invalid value for parameter `project_id` when calling `update_insight`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'project_owner' in params: - path_params['projectOwner'] = params['project_owner'] - if 'project_id' in params: - path_params['projectId'] = params['project_id'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/insights/{projectOwner}/{projectId}/{id}', 'PATCH', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) diff --git a/datadotworld/client/_swagger/apis/projects_api.py b/datadotworld/client/_swagger/apis/projects_api.py deleted file mode 100644 index 9b4187e..0000000 --- a/datadotworld/client/_swagger/apis/projects_api.py +++ /dev/null @@ -1,875 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import sys -import os -import re - -# python 2 and python 3 compatibility library -from six import iteritems - -from ..configuration import Configuration -from ..api_client import ApiClient - - -class ProjectsApi(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - Ref: https://github.com/swagger-api/swagger-codegen - """ - - def __init__(self, api_client=None): - config = Configuration() - if api_client: - self.api_client = api_client - else: - if not config.api_client: - config.api_client = ApiClient() - self.api_client = config.api_client - - def add_linked_dataset(self, owner, id, linked_dataset_owner, linked_dataset_id, **kwargs): - """ - Link dataset - Add a linked dataset to a project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.add_linked_dataset(owner, id, linked_dataset_owner, linked_dataset_id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :param str linked_dataset_owner: (required) - :param str linked_dataset_id: (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.add_linked_dataset_with_http_info(owner, id, linked_dataset_owner, linked_dataset_id, **kwargs) - else: - (data) = self.add_linked_dataset_with_http_info(owner, id, linked_dataset_owner, linked_dataset_id, **kwargs) - return data - - def add_linked_dataset_with_http_info(self, owner, id, linked_dataset_owner, linked_dataset_id, **kwargs): - """ - Link dataset - Add a linked dataset to a project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.add_linked_dataset_with_http_info(owner, id, linked_dataset_owner, linked_dataset_id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :param str linked_dataset_owner: (required) - :param str linked_dataset_id: (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'linked_dataset_owner', 'linked_dataset_id'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method add_linked_dataset" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `add_linked_dataset`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `add_linked_dataset`") - # verify the required parameter 'linked_dataset_owner' is set - if ('linked_dataset_owner' not in params) or (params['linked_dataset_owner'] is None): - raise ValueError("Missing the required parameter `linked_dataset_owner` when calling `add_linked_dataset`") - # verify the required parameter 'linked_dataset_id' is set - if ('linked_dataset_id' not in params) or (params['linked_dataset_id'] is None): - raise ValueError("Missing the required parameter `linked_dataset_id` when calling `add_linked_dataset`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `add_linked_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `add_linked_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - if 'linked_dataset_owner' in params: - path_params['linkedDatasetOwner'] = params['linked_dataset_owner'] - if 'linked_dataset_id' in params: - path_params['linkedDatasetId'] = params['linked_dataset_id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/projects/{owner}/{id}/linkedDatasets/{linkedDatasetOwner}/{linkedDatasetId}', 'PUT', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def create_project(self, owner, **kwargs): - """ - Create a project - Create a new project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.create_project(owner, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param ProjectCreateRequest body: - :return: CreateProjectResponse - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.create_project_with_http_info(owner, **kwargs) - else: - (data) = self.create_project_with_http_info(owner, **kwargs) - return data - - def create_project_with_http_info(self, owner, **kwargs): - """ - Create a project - Create a new project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.create_project_with_http_info(owner, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param ProjectCreateRequest body: - :return: CreateProjectResponse - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'body'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method create_project" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `create_project`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `create_project`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/projects/{owner}', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='CreateProjectResponse', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def delete_project(self, owner, id, **kwargs): - """ - Delete a project - Permanently deletes a project and all data associated with it. This operation cannot be undone, although a new project may be created with the same id. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_project(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.delete_project_with_http_info(owner, id, **kwargs) - else: - (data) = self.delete_project_with_http_info(owner, id, **kwargs) - return data - - def delete_project_with_http_info(self, owner, id, **kwargs): - """ - Delete a project - Permanently deletes a project and all data associated with it. This operation cannot be undone, although a new project may be created with the same id. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_project_with_http_info(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_project" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `delete_project`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `delete_project`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `delete_project`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `delete_project`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/projects/{owner}/{id}', 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def get_project(self, owner, id, **kwargs): - """ - Retrieve a project - Return details on a project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.get_project(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :return: ProjectSummaryResponse - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.get_project_with_http_info(owner, id, **kwargs) - else: - (data) = self.get_project_with_http_info(owner, id, **kwargs) - return data - - def get_project_with_http_info(self, owner, id, **kwargs): - """ - Retrieve a project - Return details on a project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.get_project_with_http_info(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :return: ProjectSummaryResponse - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_project" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `get_project`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `get_project`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `get_project`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `get_project`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/projects/{owner}/{id}', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='ProjectSummaryResponse', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def patch_project(self, owner, id, **kwargs): - """ - Update a project - Update an existing project. Note that only elements, files or linked datasets included in the request will be updated. All omitted elements, files or linked datasets will remain untouched. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.patch_project(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :param ProjectPatchRequest body: - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.patch_project_with_http_info(owner, id, **kwargs) - else: - (data) = self.patch_project_with_http_info(owner, id, **kwargs) - return data - - def patch_project_with_http_info(self, owner, id, **kwargs): - """ - Update a project - Update an existing project. Note that only elements, files or linked datasets included in the request will be updated. All omitted elements, files or linked datasets will remain untouched. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.patch_project_with_http_info(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :param ProjectPatchRequest body: - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'body'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method patch_project" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `patch_project`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `patch_project`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `patch_project`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `patch_project`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/projects/{owner}/{id}', 'PATCH', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def remove_linked_dataset(self, owner, id, linked_dataset_owner, linked_dataset_id, **kwargs): - """ - Unlink dataset - Remove a linked dataset from a project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.remove_linked_dataset(owner, id, linked_dataset_owner, linked_dataset_id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :param str linked_dataset_owner: (required) - :param str linked_dataset_id: (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.remove_linked_dataset_with_http_info(owner, id, linked_dataset_owner, linked_dataset_id, **kwargs) - else: - (data) = self.remove_linked_dataset_with_http_info(owner, id, linked_dataset_owner, linked_dataset_id, **kwargs) - return data - - def remove_linked_dataset_with_http_info(self, owner, id, linked_dataset_owner, linked_dataset_id, **kwargs): - """ - Unlink dataset - Remove a linked dataset from a project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.remove_linked_dataset_with_http_info(owner, id, linked_dataset_owner, linked_dataset_id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :param str linked_dataset_owner: (required) - :param str linked_dataset_id: (required) - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'linked_dataset_owner', 'linked_dataset_id'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method remove_linked_dataset" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `remove_linked_dataset`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `remove_linked_dataset`") - # verify the required parameter 'linked_dataset_owner' is set - if ('linked_dataset_owner' not in params) or (params['linked_dataset_owner'] is None): - raise ValueError("Missing the required parameter `linked_dataset_owner` when calling `remove_linked_dataset`") - # verify the required parameter 'linked_dataset_id' is set - if ('linked_dataset_id' not in params) or (params['linked_dataset_id'] is None): - raise ValueError("Missing the required parameter `linked_dataset_id` when calling `remove_linked_dataset`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `remove_linked_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `remove_linked_dataset`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - if 'linked_dataset_owner' in params: - path_params['linkedDatasetOwner'] = params['linked_dataset_owner'] - if 'linked_dataset_id' in params: - path_params['linkedDatasetId'] = params['linked_dataset_id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/projects/{owner}/{id}/linkedDatasets/{linkedDatasetOwner}/{linkedDatasetId}', 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def replace_project(self, owner, id, **kwargs): - """ - Create / Replace a project - Create a project with a given id or completely rewrite the project, including any previously added files or linked datasets, if one already exists with the given id. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.replace_project(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :param ProjectCreateRequest body: - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.replace_project_with_http_info(owner, id, **kwargs) - else: - (data) = self.replace_project_with_http_info(owner, id, **kwargs) - return data - - def replace_project_with_http_info(self, owner, id, **kwargs): - """ - Create / Replace a project - Create a project with a given id or completely rewrite the project, including any previously added files or linked datasets, if one already exists with the given id. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.replace_project_with_http_info(owner, id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a project. For example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner. (required) - :param str id: Project unique identifier. For example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project. (required) - :param ProjectCreateRequest body: - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'body'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method replace_project" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `replace_project`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `replace_project`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `replace_project`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `replace_project`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/projects/{owner}/{id}', 'PUT', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) diff --git a/datadotworld/client/_swagger/apis/sparql_api.py b/datadotworld/client/_swagger/apis/sparql_api.py deleted file mode 100644 index bc5c6d8..0000000 --- a/datadotworld/client/_swagger/apis/sparql_api.py +++ /dev/null @@ -1,285 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import sys -import os -import re - -# python 2 and python 3 compatibility library -from six import iteritems - -from ..configuration import Configuration -from ..api_client import ApiClient - - -class SparqlApi(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - Ref: https://github.com/swagger-api/swagger-codegen - """ - - def __init__(self, api_client=None): - config = Configuration() - if api_client: - self.api_client = api_client - else: - if not config.api_client: - config.api_client = ApiClient() - self.api_client = config.api_client - - def sparql_get(self, owner, id, query, **kwargs): - """ - SPARQL query (via GET) - This endpoint executes SPARQL queries against a dataset or data project. SPARQL results are available in a variety of formats. By default, `application/sparql-results+json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: - `application/sparql-results+xml` - `application/sparql-results+json` - `application/rdf+json` - `application/rdf+xml` - `text/csv` - `text/tab-separated-values` New to SPARQL? Check out data.world’s[SPARQL tutorial](https://docs.data.world/tutorials/sparql/). - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sparql_get(owner, id, query, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str query: (required) - :return: None - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.sparql_get_with_http_info(owner, id, query, **kwargs) - else: - (data) = self.sparql_get_with_http_info(owner, id, query, **kwargs) - return data - - def sparql_get_with_http_info(self, owner, id, query, **kwargs): - """ - SPARQL query (via GET) - This endpoint executes SPARQL queries against a dataset or data project. SPARQL results are available in a variety of formats. By default, `application/sparql-results+json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: - `application/sparql-results+xml` - `application/sparql-results+json` - `application/rdf+json` - `application/rdf+xml` - `text/csv` - `text/tab-separated-values` New to SPARQL? Check out data.world’s[SPARQL tutorial](https://docs.data.world/tutorials/sparql/). - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sparql_get_with_http_info(owner, id, query, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str query: (required) - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'query'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method sparql_get" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `sparql_get`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `sparql_get`") - # verify the required parameter 'query' is set - if ('query' not in params) or (params['query'] is None): - raise ValueError("Missing the required parameter `query` when calling `sparql_get`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `sparql_get`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `sparql_get`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - if 'query' in params: - query_params.append(('query', params['query'])) - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/sparql-results+json', 'application/sparql-results+xml', 'application/rdf+json', 'application/rdf+xml', 'text/tab-separated-values', 'text/csv']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/sparql/{owner}/{id}', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def sparql_post(self, owner, id, query, **kwargs): - """ - SPARQL query - This endpoint executes SPARQL queries against a dataset or data project. SPARQL results are available in a variety of formats. By default, `application/sparql-results+json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: - `application/sparql-results+xml` - `application/sparql-results+json` - `application/rdf+json` - `application/rdf+xml` - `text/csv` - `text/tab-separated-values` New to SPARQL? Check out data.world's [SPARQL tutorial](https://docs.data.world/tutorials/sparql/). - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sparql_post(owner, id, query, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str query: (required) - :return: None - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.sparql_post_with_http_info(owner, id, query, **kwargs) - else: - (data) = self.sparql_post_with_http_info(owner, id, query, **kwargs) - return data - - def sparql_post_with_http_info(self, owner, id, query, **kwargs): - """ - SPARQL query - This endpoint executes SPARQL queries against a dataset or data project. SPARQL results are available in a variety of formats. By default, `application/sparql-results+json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: - `application/sparql-results+xml` - `application/sparql-results+json` - `application/rdf+json` - `application/rdf+xml` - `text/csv` - `text/tab-separated-values` New to SPARQL? Check out data.world's [SPARQL tutorial](https://docs.data.world/tutorials/sparql/). - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sparql_post_with_http_info(owner, id, query, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str query: (required) - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'query'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method sparql_post" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `sparql_post`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `sparql_post`") - # verify the required parameter 'query' is set - if ('query' not in params) or (params['query'] is None): - raise ValueError("Missing the required parameter `query` when calling `sparql_post`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `sparql_post`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `sparql_post`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - if 'query' in params: - form_params.append(('query', params['query'])) - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/sparql-results+json', 'application/sparql-results+xml', 'application/rdf+json', 'application/rdf+xml', 'text/tab-separated-values', 'text/csv']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/x-www-form-urlencoded']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/sparql/{owner}/{id}', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) diff --git a/datadotworld/client/_swagger/apis/sql_api.py b/datadotworld/client/_swagger/apis/sql_api.py deleted file mode 100644 index 981ec0d..0000000 --- a/datadotworld/client/_swagger/apis/sql_api.py +++ /dev/null @@ -1,293 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import sys -import os -import re - -# python 2 and python 3 compatibility library -from six import iteritems - -from ..configuration import Configuration -from ..api_client import ApiClient - - -class SqlApi(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - Ref: https://github.com/swagger-api/swagger-codegen - """ - - def __init__(self, api_client=None): - config = Configuration() - if api_client: - self.api_client = api_client - else: - if not config.api_client: - config.api_client = ApiClient() - self.api_client = config.api_client - - def sql_get(self, owner, id, query, **kwargs): - """ - SQL query (via GET) - This endpoint executes SQL queries against a dataset. SQL results are available in a variety of formats. By default, `application/json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: * `text/csv` * `application/json` * `application/json-l` * `application/x-ndjson` New to SQL? Check out data.world's [SQL manual](https://docs.data.world/tutorials/dwsql/) . - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sql_get(owner, id, query, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str query: (required) - :param bool include_table_schema: Flags indicating to include table schema in the response. - :return: None - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.sql_get_with_http_info(owner, id, query, **kwargs) - else: - (data) = self.sql_get_with_http_info(owner, id, query, **kwargs) - return data - - def sql_get_with_http_info(self, owner, id, query, **kwargs): - """ - SQL query (via GET) - This endpoint executes SQL queries against a dataset. SQL results are available in a variety of formats. By default, `application/json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: * `text/csv` * `application/json` * `application/json-l` * `application/x-ndjson` New to SQL? Check out data.world's [SQL manual](https://docs.data.world/tutorials/dwsql/) . - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sql_get_with_http_info(owner, id, query, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str query: (required) - :param bool include_table_schema: Flags indicating to include table schema in the response. - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'query', 'include_table_schema'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method sql_get" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `sql_get`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `sql_get`") - # verify the required parameter 'query' is set - if ('query' not in params) or (params['query'] is None): - raise ValueError("Missing the required parameter `query` when calling `sql_get`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `sql_get`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `sql_get`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - if 'query' in params: - query_params.append(('query', params['query'])) - if 'include_table_schema' in params: - query_params.append(('includeTableSchema', params['include_table_schema'])) - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json', 'application/json-l', 'application/x-ndjson', 'text/csv']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/sql/{owner}/{id}', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def sql_post(self, owner, id, query, **kwargs): - """ - SQL query - This endpoint executes SQL queries against a dataset. SQL results are available in a variety of formats. By default, `application/json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: * `text/csv` * `application/json` * `application/json-l` * `application/x-ndjson` New to SQL? Check out data.world's [SQL manual](https://docs.data.world/tutorials/dwsql/) . - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sql_post(owner, id, query, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str query: (required) - :param bool include_table_schema: Flags indicating to include table schema in the response. - :return: None - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.sql_post_with_http_info(owner, id, query, **kwargs) - else: - (data) = self.sql_post_with_http_info(owner, id, query, **kwargs) - return data - - def sql_post_with_http_info(self, owner, id, query, **kwargs): - """ - SQL query - This endpoint executes SQL queries against a dataset. SQL results are available in a variety of formats. By default, `application/json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference: * `text/csv` * `application/json` * `application/json-l` * `application/x-ndjson` New to SQL? Check out data.world's [SQL manual](https://docs.data.world/tutorials/dwsql/) . - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.sql_post_with_http_info(owner, id, query, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str query: (required) - :param bool include_table_schema: Flags indicating to include table schema in the response. - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'query', 'include_table_schema'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method sql_post" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `sql_post`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `sql_post`") - # verify the required parameter 'query' is set - if ('query' not in params) or (params['query'] is None): - raise ValueError("Missing the required parameter `query` when calling `sql_post`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `sql_post`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `sql_post`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - if 'include_table_schema' in params: - query_params.append(('includeTableSchema', params['include_table_schema'])) - - header_params = {} - - form_params = [] - local_var_files = {} - if 'query' in params: - form_params.append(('query', params['query'])) - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json', 'application/json-l', 'application/x-ndjson', 'text/csv']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/x-www-form-urlencoded']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/sql/{owner}/{id}', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) diff --git a/datadotworld/client/_swagger/apis/streams_api.py b/datadotworld/client/_swagger/apis/streams_api.py deleted file mode 100644 index 30ce713..0000000 --- a/datadotworld/client/_swagger/apis/streams_api.py +++ /dev/null @@ -1,174 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import sys -import os -import re - -# python 2 and python 3 compatibility library -from six import iteritems - -from ..configuration import Configuration -from ..api_client import ApiClient - - -class StreamsApi(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - Ref: https://github.com/swagger-api/swagger-codegen - """ - - def __init__(self, api_client=None): - config = Configuration() - if api_client: - self.api_client = api_client - else: - if not config.api_client: - config.api_client = ApiClient() - self.api_client = config.api_client - - def append_records(self, owner, id, stream_id, body, **kwargs): - """ - Append records to a stream. - This endpoint appends JSON data to a stream associated with a dataset. Streams don't need to be created before you can append data to it. They will be created on-demand, the first time they are used. Multiple records can be appended at once by using JSON-L (`application/json-l`) as the request content type. Currently, data uploaded to a dataset via a stream is not immediatelly processed. Instead, it is processed automatically at least once a day or as a result of a \"Sync files\" endpoint invocation. Once processed, the contents of a stream will appear as part of the respective dataset as a `.jsonl` file (e.g. `my-stream` will produce a file named `my-stream.jsonl`). - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.append_records(owner, id, stream_id, body, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str stream_id: Stream unique identifier as defined by the user the first time the stream was used. Only lower case letters, numbers and dashes are allowed. Maximum length of 95 characters. (required) - :param object body: (required) - :return: None - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.append_records_with_http_info(owner, id, stream_id, body, **kwargs) - else: - (data) = self.append_records_with_http_info(owner, id, stream_id, body, **kwargs) - return data - - def append_records_with_http_info(self, owner, id, stream_id, body, **kwargs): - """ - Append records to a stream. - This endpoint appends JSON data to a stream associated with a dataset. Streams don't need to be created before you can append data to it. They will be created on-demand, the first time they are used. Multiple records can be appended at once by using JSON-L (`application/json-l`) as the request content type. Currently, data uploaded to a dataset via a stream is not immediatelly processed. Instead, it is processed automatically at least once a day or as a result of a \"Sync files\" endpoint invocation. Once processed, the contents of a stream will appear as part of the respective dataset as a `.jsonl` file (e.g. `my-stream` will produce a file named `my-stream.jsonl`). - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.append_records_with_http_info(owner, id, stream_id, body, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str stream_id: Stream unique identifier as defined by the user the first time the stream was used. Only lower case letters, numbers and dashes are allowed. Maximum length of 95 characters. (required) - :param object body: (required) - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'stream_id', 'body'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method append_records" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `append_records`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `append_records`") - # verify the required parameter 'stream_id' is set - if ('stream_id' not in params) or (params['stream_id'] is None): - raise ValueError("Missing the required parameter `stream_id` when calling `append_records`") - # verify the required parameter 'body' is set - if ('body' not in params) or (params['body'] is None): - raise ValueError("Missing the required parameter `body` when calling `append_records`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `append_records`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `append_records`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'stream_id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9]){1,93}[a-z0-9]', params['stream_id']): - raise ValueError("Invalid value for parameter `stream_id` when calling `append_records`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9]){1,93}[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - if 'stream_id' in params: - path_params['streamId'] = params['stream_id'] - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json-l', 'application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/streams/{owner}/{id}/{streamId}', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) diff --git a/datadotworld/client/_swagger/apis/uploads_api.py b/datadotworld/client/_swagger/apis/uploads_api.py deleted file mode 100644 index 48fd6b2..0000000 --- a/datadotworld/client/_swagger/apis/uploads_api.py +++ /dev/null @@ -1,301 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import sys -import os -import re - -# python 2 and python 3 compatibility library -from six import iteritems - -from ..configuration import Configuration -from ..api_client import ApiClient - - -class UploadsApi(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - Ref: https://github.com/swagger-api/swagger-codegen - """ - - def __init__(self, api_client=None): - config = Configuration() - if api_client: - self.api_client = api_client - else: - if not config.api_client: - config.api_client = ApiClient() - self.api_client = config.api_client - - def upload_file(self, owner, id, name, **kwargs): - """ - Upload file - Upload one file at a time to a dataset. This endpoint expects requests of type `application/octet-stream`. For example, assuming that you want to upload a local file named `file1.csv` to a hypothetical dataset `https://data.world/awesome-user/awesome-dataset` and choose its name on data.world to be `better-name.csv`, this is what the cURL command would look like. ```bash curl \\ -H \"Authorization: Bearer \" \\ -X PUT -H \"Content-Type: application/octet-stream\" \\ --data-binary @file1.csv \\ https://api.data.world/v0/uploads/awesome-user/awesome-dataset/files/better-name.csv ``` This method of upload is typically not supported by Swagger clients. Other HTTP clients can be used to supply the contents of the file directly in the body of the request. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.upload_file(owner, id, name, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str name: File name and unique identifier within dataset. (required) - :param bool expand_archive: Indicates whether a compressed file should be expanded upon upload. - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.upload_file_with_http_info(owner, id, name, **kwargs) - else: - (data) = self.upload_file_with_http_info(owner, id, name, **kwargs) - return data - - def upload_file_with_http_info(self, owner, id, name, **kwargs): - """ - Upload file - Upload one file at a time to a dataset. This endpoint expects requests of type `application/octet-stream`. For example, assuming that you want to upload a local file named `file1.csv` to a hypothetical dataset `https://data.world/awesome-user/awesome-dataset` and choose its name on data.world to be `better-name.csv`, this is what the cURL command would look like. ```bash curl \\ -H \"Authorization: Bearer \" \\ -X PUT -H \"Content-Type: application/octet-stream\" \\ --data-binary @file1.csv \\ https://api.data.world/v0/uploads/awesome-user/awesome-dataset/files/better-name.csv ``` This method of upload is typically not supported by Swagger clients. Other HTTP clients can be used to supply the contents of the file directly in the body of the request. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.upload_file_with_http_info(owner, id, name, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param str name: File name and unique identifier within dataset. (required) - :param bool expand_archive: Indicates whether a compressed file should be expanded upon upload. - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'name', 'expand_archive'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method upload_file" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `upload_file`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `upload_file`") - # verify the required parameter 'name' is set - if ('name' not in params) or (params['name'] is None): - raise ValueError("Missing the required parameter `name` when calling `upload_file`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `upload_file`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `upload_file`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'name' in params and len(params['name']) > 128: - raise ValueError("Invalid value for parameter `name` when calling `upload_file`, number of items must be less than or equal to `128`") - if 'name' in params and len(params['name']) < 1: - raise ValueError("Invalid value for parameter `name` when calling `upload_file`, number of items must be greater than or equal to `1`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - if 'name' in params: - path_params['name'] = params['name'] - - query_params = [] - if 'expand_archive' in params: - query_params.append(('expandArchive', params['expand_archive'])) - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/octet-stream', '*/*']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/uploads/{owner}/{id}/files/{name}', 'PUT', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def upload_files(self, owner, id, file, **kwargs): - """ - Upload files - Upload multiple files at once to a dataset via multipart request. This endpoint expects requests of type `multipart/form-data` and you can include one or more parts named `file`, each containing a different file to be uploaded. For example, assuming that, you want to upload two local files named `file1.csv` and `file2.csv` to a hypothetical dataset `https://data.world/awesome-user/awesome-dataset`, this is what the cURL command would look like. ```bash curl \\ -H \"Authorization: Bearer \" \\ -F \"file=@file1.csv\" \\ -F \"file=@file2.csv\" \\ https://api.data.world/v0/uploads/awesome-user/awesome-dataset/files ``` Swagger clients will limit this method of upload to one file at a time. Other HTTP clients capable of making multipart/form-data requests can be used to upload multiple files in a single request. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.upload_files(owner, id, file, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param file file: Multipart-encoded file contents (required) - :param bool expand_archives: Indicates whether compressed files should be expanded upon upload. - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.upload_files_with_http_info(owner, id, file, **kwargs) - else: - (data) = self.upload_files_with_http_info(owner, id, file, **kwargs) - return data - - def upload_files_with_http_info(self, owner, id, file, **kwargs): - """ - Upload files - Upload multiple files at once to a dataset via multipart request. This endpoint expects requests of type `multipart/form-data` and you can include one or more parts named `file`, each containing a different file to be uploaded. For example, assuming that, you want to upload two local files named `file1.csv` and `file2.csv` to a hypothetical dataset `https://data.world/awesome-user/awesome-dataset`, this is what the cURL command would look like. ```bash curl \\ -H \"Authorization: Bearer \" \\ -F \"file=@file1.csv\" \\ -F \"file=@file2.csv\" \\ https://api.data.world/v0/uploads/awesome-user/awesome-dataset/files ``` Swagger clients will limit this method of upload to one file at a time. Other HTTP clients capable of making multipart/form-data requests can be used to upload multiple files in a single request. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.upload_files_with_http_info(owner, id, file, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str owner: User name and unique identifier of the creator of a dataset or project. For example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner. (required) - :param str id: Dataset unique identifier. For example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset. (required) - :param file file: Multipart-encoded file contents (required) - :param bool expand_archives: Indicates whether compressed files should be expanded upon upload. - :return: SuccessMessage - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['owner', 'id', 'file', 'expand_archives'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method upload_files" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'owner' is set - if ('owner' not in params) or (params['owner'] is None): - raise ValueError("Missing the required parameter `owner` when calling `upload_files`") - # verify the required parameter 'id' is set - if ('id' not in params) or (params['id'] is None): - raise ValueError("Missing the required parameter `id` when calling `upload_files`") - # verify the required parameter 'file' is set - if ('file' not in params) or (params['file'] is None): - raise ValueError("Missing the required parameter `file` when calling `upload_files`") - - if 'owner' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['owner']): - raise ValueError("Invalid value for parameter `owner` when calling `upload_files`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - if 'id' in params and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', params['id']): - raise ValueError("Invalid value for parameter `id` when calling `upload_files`, must conform to the pattern `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - collection_formats = {} - - path_params = {} - if 'owner' in params: - path_params['owner'] = params['owner'] - if 'id' in params: - path_params['id'] = params['id'] - - query_params = [] - if 'expand_archives' in params: - query_params.append(('expandArchives', params['expand_archives'])) - - header_params = {} - - form_params = [] - local_var_files = {} - if 'file' in params: - local_var_files['file'] = params['file'] - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['multipart/form-data']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/uploads/{owner}/{id}/files', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='SuccessMessage', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) diff --git a/datadotworld/client/_swagger/apis/user_api.py b/datadotworld/client/_swagger/apis/user_api.py deleted file mode 100644 index a6fd849..0000000 --- a/datadotworld/client/_swagger/apis/user_api.py +++ /dev/null @@ -1,726 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import sys -import os -import re - -# python 2 and python 3 compatibility library -from six import iteritems - -from ..configuration import Configuration -from ..api_client import ApiClient - - -class UserApi(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - Ref: https://github.com/swagger-api/swagger-codegen - """ - - def __init__(self, api_client=None): - config = Configuration() - if api_client: - self.api_client = api_client - else: - if not config.api_client: - config.api_client = ApiClient() - self.api_client = config.api_client - - def fetch_contributing_datasets(self, **kwargs): - """ - List datasets as contributor - Fetch datasets that the currently authenticated user has access to because he or she is a contributor. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_contributing_datasets(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str limit: Maximum number of items to include in a page of results. - :param str next: Token from previous result page to be used when requesting a subsequent page. - :return: PaginatedDatasetResults - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.fetch_contributing_datasets_with_http_info(**kwargs) - else: - (data) = self.fetch_contributing_datasets_with_http_info(**kwargs) - return data - - def fetch_contributing_datasets_with_http_info(self, **kwargs): - """ - List datasets as contributor - Fetch datasets that the currently authenticated user has access to because he or she is a contributor. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_contributing_datasets_with_http_info(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str limit: Maximum number of items to include in a page of results. - :param str next: Token from previous result page to be used when requesting a subsequent page. - :return: PaginatedDatasetResults - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['limit', 'next'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method fetch_contributing_datasets" % key - ) - params[key] = val - del params['kwargs'] - - - collection_formats = {} - - path_params = {} - - query_params = [] - if 'limit' in params: - query_params.append(('limit', params['limit'])) - if 'next' in params: - query_params.append(('next', params['next'])) - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/user/datasets/contributing', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='PaginatedDatasetResults', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def fetch_contributing_projects(self, **kwargs): - """ - List projects as contributor - Fetch projects that the currently authenticated user has access to because he or she is a contributor. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_contributing_projects(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :return: PaginatedProjectResults - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.fetch_contributing_projects_with_http_info(**kwargs) - else: - (data) = self.fetch_contributing_projects_with_http_info(**kwargs) - return data - - def fetch_contributing_projects_with_http_info(self, **kwargs): - """ - List projects as contributor - Fetch projects that the currently authenticated user has access to because he or she is a contributor. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_contributing_projects_with_http_info(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :return: PaginatedProjectResults - If the method is called asynchronously, - returns the request thread. - """ - - all_params = [] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method fetch_contributing_projects" % key - ) - params[key] = val - del params['kwargs'] - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/user/projects/contributing', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='PaginatedProjectResults', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def fetch_datasets(self, **kwargs): - """ - List datasets as owner - Fetch datasets that the currently authenticated user has access to because he or she is the owner of the dataset. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_datasets(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str limit: Maximum number of items to include in a page of results. - :param str next: Token from previous result page to be used when requesting a subsequent page. - :return: PaginatedDatasetResults - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.fetch_datasets_with_http_info(**kwargs) - else: - (data) = self.fetch_datasets_with_http_info(**kwargs) - return data - - def fetch_datasets_with_http_info(self, **kwargs): - """ - List datasets as owner - Fetch datasets that the currently authenticated user has access to because he or she is the owner of the dataset. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_datasets_with_http_info(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str limit: Maximum number of items to include in a page of results. - :param str next: Token from previous result page to be used when requesting a subsequent page. - :return: PaginatedDatasetResults - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['limit', 'next'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method fetch_datasets" % key - ) - params[key] = val - del params['kwargs'] - - - collection_formats = {} - - path_params = {} - - query_params = [] - if 'limit' in params: - query_params.append(('limit', params['limit'])) - if 'next' in params: - query_params.append(('next', params['next'])) - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/user/datasets/own', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='PaginatedDatasetResults', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def fetch_liked_datasets(self, **kwargs): - """ - List liked datasets - Fetch datasets that the currently authenticated user likes. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_liked_datasets(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str limit: Maximum number of items to include in a page of results. - :param str next: Token from previous result page to be used when requesting a subsequent page. - :return: PaginatedDatasetResults - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.fetch_liked_datasets_with_http_info(**kwargs) - else: - (data) = self.fetch_liked_datasets_with_http_info(**kwargs) - return data - - def fetch_liked_datasets_with_http_info(self, **kwargs): - """ - List liked datasets - Fetch datasets that the currently authenticated user likes. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_liked_datasets_with_http_info(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str limit: Maximum number of items to include in a page of results. - :param str next: Token from previous result page to be used when requesting a subsequent page. - :return: PaginatedDatasetResults - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['limit', 'next'] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method fetch_liked_datasets" % key - ) - params[key] = val - del params['kwargs'] - - - collection_formats = {} - - path_params = {} - - query_params = [] - if 'limit' in params: - query_params.append(('limit', params['limit'])) - if 'next' in params: - query_params.append(('next', params['next'])) - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/user/datasets/liked', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='PaginatedDatasetResults', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def fetch_liked_projects(self, **kwargs): - """ - List liked projects - Fetch projects that the currently authenticated user likes. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_liked_projects(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :return: PaginatedProjectResults - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.fetch_liked_projects_with_http_info(**kwargs) - else: - (data) = self.fetch_liked_projects_with_http_info(**kwargs) - return data - - def fetch_liked_projects_with_http_info(self, **kwargs): - """ - List liked projects - Fetch projects that the currently authenticated user likes. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_liked_projects_with_http_info(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :return: PaginatedProjectResults - If the method is called asynchronously, - returns the request thread. - """ - - all_params = [] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method fetch_liked_projects" % key - ) - params[key] = val - del params['kwargs'] - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/user/projects/liked', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='PaginatedProjectResults', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def fetch_projects(self, **kwargs): - """ - List projects owned - Fetch projects that the currently authenticated user has access to because he or she is the owner of the project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_projects(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :return: PaginatedProjectResults - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.fetch_projects_with_http_info(**kwargs) - else: - (data) = self.fetch_projects_with_http_info(**kwargs) - return data - - def fetch_projects_with_http_info(self, **kwargs): - """ - List projects owned - Fetch projects that the currently authenticated user has access to because he or she is the owner of the project. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fetch_projects_with_http_info(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :return: PaginatedProjectResults - If the method is called asynchronously, - returns the request thread. - """ - - all_params = [] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method fetch_projects" % key - ) - params[key] = val - del params['kwargs'] - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/user/projects/own', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='PaginatedProjectResults', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - def get_user_data(self, **kwargs): - """ - Get user data - Return profile information for the currently authenticated user. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.get_user_data(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :return: UserDataResponse - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): - return self.get_user_data_with_http_info(**kwargs) - else: - (data) = self.get_user_data_with_http_info(**kwargs) - return data - - def get_user_data_with_http_info(self, **kwargs): - """ - Get user data - Return profile information for the currently authenticated user. - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.get_user_data_with_http_info(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :return: UserDataResponse - If the method is called asynchronously, - returns the request thread. - """ - - all_params = [] - all_params.append('callback') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_user_data" % key - ) - params[key] = val - del params['kwargs'] - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json']) - - # Authentication setting - auth_settings = ['token'] - - return self.api_client.call_api('/user', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='UserDataResponse', - auth_settings=auth_settings, - callback=params.get('callback'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) diff --git a/datadotworld/client/_swagger/configuration.py b/datadotworld/client/_swagger/configuration.py deleted file mode 100644 index 884ab62..0000000 --- a/datadotworld/client/_swagger/configuration.py +++ /dev/null @@ -1,231 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import urllib3 - -import sys -import logging - -from six import iteritems -from six.moves import http_client as httplib - - -def singleton(cls, *args, **kw): - instances = {} - - def _singleton(): - if cls not in instances: - instances[cls] = cls(*args, **kw) - return instances[cls] - return _singleton - - -@singleton -class Configuration(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Ref: https://github.com/swagger-api/swagger-codegen - Do not edit the class manually. - """ - - def __init__(self): - """ - Constructor - """ - # Default Base url - self.host = "https://api.data.world/v0" - # Default api client - self.api_client = None - # Temp file folder for downloading files - self.temp_folder_path = None - - # Authentication Settings - # dict to store API key(s) - self.api_key = {} - # dict to store API prefix (e.g. Bearer) - self.api_key_prefix = {} - # Username for HTTP basic authentication - self.username = "" - # Password for HTTP basic authentication - self.password = "" - - # Logging Settings - self.logger = {} - self.logger["package_logger"] = logging.getLogger("_swagger") - self.logger["urllib3_logger"] = logging.getLogger("urllib3") - # Log format - self.logger_format = '%(asctime)s %(levelname)s %(message)s' - # Log stream handler - self.logger_stream_handler = None - # Log file handler - self.logger_file_handler = None - # Debug file location - self.logger_file = None - # Debug switch - self.debug = False - - # SSL/TLS verification - # Set this to false to skip verifying SSL certificate when calling API from https server. - self.verify_ssl = True - # Set this to customize the certificate file to verify the peer. - self.ssl_ca_cert = None - # client certificate file - self.cert_file = None - # client key file - self.key_file = None - - # Proxy URL - self.proxy = None - # Safe chars for path_param - self.safe_chars_for_path_param = '' - - @property - def logger_file(self): - """ - Gets the logger_file. - """ - return self.__logger_file - - @logger_file.setter - def logger_file(self, value): - """ - Sets the logger_file. - - If the logger_file is None, then add stream handler and remove file handler. - Otherwise, add file handler and remove stream handler. - - :param value: The logger_file path. - :type: str - """ - self.__logger_file = value - if self.__logger_file: - # If set logging file, - # then add file handler and remove stream handler. - self.logger_file_handler = logging.FileHandler(self.__logger_file) - self.logger_file_handler.setFormatter(self.logger_formatter) - for _, logger in iteritems(self.logger): - logger.addHandler(self.logger_file_handler) - if self.logger_stream_handler: - logger.removeHandler(self.logger_stream_handler) - else: - # If not set logging file, - # then add stream handler and remove file handler. - self.logger_stream_handler = logging.StreamHandler() - self.logger_stream_handler.setFormatter(self.logger_formatter) - for _, logger in iteritems(self.logger): - logger.addHandler(self.logger_stream_handler) - if self.logger_file_handler: - logger.removeHandler(self.logger_file_handler) - - @property - def debug(self): - """ - Gets the debug status. - """ - return self.__debug - - @debug.setter - def debug(self, value): - """ - Sets the debug status. - - :param value: The debug status, True or False. - :type: bool - """ - self.__debug = value - if self.__debug: - # if debug status is True, turn on debug logging - for _, logger in iteritems(self.logger): - logger.setLevel(logging.DEBUG) - # turn on httplib debug - httplib.HTTPConnection.debuglevel = 1 - else: - # if debug status is False, turn off debug logging, - # setting log level to default `logging.WARNING` - for _, logger in iteritems(self.logger): - logger.setLevel(logging.WARNING) - # turn off httplib debug - httplib.HTTPConnection.debuglevel = 0 - - @property - def logger_format(self): - """ - Gets the logger_format. - """ - return self.__logger_format - - @logger_format.setter - def logger_format(self, value): - """ - Sets the logger_format. - - The logger_formatter will be updated when sets logger_format. - - :param value: The format string. - :type: str - """ - self.__logger_format = value - self.logger_formatter = logging.Formatter(self.__logger_format) - - def get_api_key_with_prefix(self, identifier): - """ - Gets API key (with prefix if set). - - :param identifier: The identifier of apiKey. - :return: The token for api key authentication. - """ - if self.api_key.get(identifier) and self.api_key_prefix.get(identifier): - return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] - elif self.api_key.get(identifier): - return self.api_key[identifier] - - def get_basic_auth_token(self): - """ - Gets HTTP basic authentication header (string). - - :return: The token for basic HTTP authentication. - """ - return urllib3.util.make_headers(basic_auth=self.username + ':' + self.password)\ - .get('authorization') - - def auth_settings(self): - """ - Gets Auth Settings dict for api client. - - :return: The Auth Settings information dict. - """ - return { - 'token': - { - 'type': 'api_key', - 'in': 'header', - 'key': 'Authorization', - 'value': self.get_api_key_with_prefix('Authorization') - }, - - } - - def to_debug_report(self): - """ - Gets the essential information for debugging. - - :return: The report for debugging. - """ - return "Python SDK Debug Report:\n"\ - "OS: {env}\n"\ - "Python Version: {pyversion}\n"\ - "Version of the API: 0.14.1\n"\ - "SDK Package Version: 1.0.0".\ - format(env=sys.platform, pyversion=sys.version) diff --git a/datadotworld/client/_swagger/models/__init__.py b/datadotworld/client/_swagger/models/__init__.py deleted file mode 100644 index 30780b7..0000000 --- a/datadotworld/client/_swagger/models/__init__.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -# import models into model package -from .create_dataset_response import CreateDatasetResponse -from .create_insight_response import CreateInsightResponse -from .create_project_response import CreateProjectResponse -from .dataset_create_request import DatasetCreateRequest -from .dataset_patch_request import DatasetPatchRequest -from .dataset_put_request import DatasetPutRequest -from .dataset_summary_response import DatasetSummaryResponse -from .error_message import ErrorMessage -from .file_batch_update_request import FileBatchUpdateRequest -from .file_create_or_update_request import FileCreateOrUpdateRequest -from .file_create_request import FileCreateRequest -from .file_source_create_or_update_request import FileSourceCreateOrUpdateRequest -from .file_source_create_request import FileSourceCreateRequest -from .file_source_summary_response import FileSourceSummaryResponse -from .file_summary_response import FileSummaryResponse -from .insight_body import InsightBody -from .insight_create_request import InsightCreateRequest -from .insight_patch_request import InsightPatchRequest -from .insight_put_request import InsightPutRequest -from .insight_summary_response import InsightSummaryResponse -from .linked_dataset_create_or_update_request import LinkedDatasetCreateOrUpdateRequest -from .linked_dataset_summary_response import LinkedDatasetSummaryResponse -from .oauth_token_reference import OauthTokenReference -from .paginated_dataset_results import PaginatedDatasetResults -from .paginated_insight_results import PaginatedInsightResults -from .paginated_project_results import PaginatedProjectResults -from .project_create_request import ProjectCreateRequest -from .project_patch_request import ProjectPatchRequest -from .project_summary_response import ProjectSummaryResponse -from .success_message import SuccessMessage -from .user_data_response import UserDataResponse -from .web_authorization import WebAuthorization -from .web_credentials import WebCredentials diff --git a/datadotworld/client/_swagger/models/create_dataset_response.py b/datadotworld/client/_swagger/models/create_dataset_response.py deleted file mode 100644 index b52f913..0000000 --- a/datadotworld/client/_swagger/models/create_dataset_response.py +++ /dev/null @@ -1,152 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class CreateDatasetResponse(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'message': 'str', - 'uri': 'str' - } - - attribute_map = { - 'message': 'message', - 'uri': 'uri' - } - - def __init__(self, message=None, uri=None): - """ - CreateDatasetResponse - a model defined in Swagger - """ - - self._message = None - self._uri = None - - if message is not None: - self.message = message - self.uri = uri - - @property - def message(self): - """ - Gets the message of this CreateDatasetResponse. - - :return: The message of this CreateDatasetResponse. - :rtype: str - """ - return self._message - - @message.setter - def message(self, message): - """ - Sets the message of this CreateDatasetResponse. - - :param message: The message of this CreateDatasetResponse. - :type: str - """ - - self._message = message - - @property - def uri(self): - """ - Gets the uri of this CreateDatasetResponse. - URI of newly created dataset. - - :return: The uri of this CreateDatasetResponse. - :rtype: str - """ - return self._uri - - @uri.setter - def uri(self, uri): - """ - Sets the uri of this CreateDatasetResponse. - URI of newly created dataset. - - :param uri: The uri of this CreateDatasetResponse. - :type: str - """ - if uri is None: - raise ValueError("Invalid value for `uri`, must not be `None`") - - self._uri = uri - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, CreateDatasetResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/create_insight_response.py b/datadotworld/client/_swagger/models/create_insight_response.py deleted file mode 100644 index 8c5d710..0000000 --- a/datadotworld/client/_swagger/models/create_insight_response.py +++ /dev/null @@ -1,152 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class CreateInsightResponse(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'message': 'str', - 'uri': 'str' - } - - attribute_map = { - 'message': 'message', - 'uri': 'uri' - } - - def __init__(self, message=None, uri=None): - """ - CreateInsightResponse - a model defined in Swagger - """ - - self._message = None - self._uri = None - - if message is not None: - self.message = message - self.uri = uri - - @property - def message(self): - """ - Gets the message of this CreateInsightResponse. - - :return: The message of this CreateInsightResponse. - :rtype: str - """ - return self._message - - @message.setter - def message(self, message): - """ - Sets the message of this CreateInsightResponse. - - :param message: The message of this CreateInsightResponse. - :type: str - """ - - self._message = message - - @property - def uri(self): - """ - Gets the uri of this CreateInsightResponse. - URI of newly created insight. - - :return: The uri of this CreateInsightResponse. - :rtype: str - """ - return self._uri - - @uri.setter - def uri(self, uri): - """ - Sets the uri of this CreateInsightResponse. - URI of newly created insight. - - :param uri: The uri of this CreateInsightResponse. - :type: str - """ - if uri is None: - raise ValueError("Invalid value for `uri`, must not be `None`") - - self._uri = uri - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, CreateInsightResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/create_project_response.py b/datadotworld/client/_swagger/models/create_project_response.py deleted file mode 100644 index 6df1557..0000000 --- a/datadotworld/client/_swagger/models/create_project_response.py +++ /dev/null @@ -1,152 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class CreateProjectResponse(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'message': 'str', - 'uri': 'str' - } - - attribute_map = { - 'message': 'message', - 'uri': 'uri' - } - - def __init__(self, message=None, uri=None): - """ - CreateProjectResponse - a model defined in Swagger - """ - - self._message = None - self._uri = None - - if message is not None: - self.message = message - self.uri = uri - - @property - def message(self): - """ - Gets the message of this CreateProjectResponse. - - :return: The message of this CreateProjectResponse. - :rtype: str - """ - return self._message - - @message.setter - def message(self, message): - """ - Sets the message of this CreateProjectResponse. - - :param message: The message of this CreateProjectResponse. - :type: str - """ - - self._message = message - - @property - def uri(self): - """ - Gets the uri of this CreateProjectResponse. - URI of newly created project. - - :return: The uri of this CreateProjectResponse. - :rtype: str - """ - return self._uri - - @uri.setter - def uri(self, uri): - """ - Sets the uri of this CreateProjectResponse. - URI of newly created project. - - :param uri: The uri of this CreateProjectResponse. - :type: str - """ - if uri is None: - raise ValueError("Invalid value for `uri`, must not be `None`") - - self._uri = uri - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, CreateProjectResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/dataset_create_request.py b/datadotworld/client/_swagger/models/dataset_create_request.py deleted file mode 100644 index 9ba1b6d..0000000 --- a/datadotworld/client/_swagger/models/dataset_create_request.py +++ /dev/null @@ -1,319 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class DatasetCreateRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'title': 'str', - 'description': 'str', - 'summary': 'str', - 'tags': 'list[str]', - 'license': 'str', - 'visibility': 'str', - 'files': 'list[FileCreateRequest]' - } - - attribute_map = { - 'title': 'title', - 'description': 'description', - 'summary': 'summary', - 'tags': 'tags', - 'license': 'license', - 'visibility': 'visibility', - 'files': 'files' - } - - def __init__(self, title=None, description=None, summary=None, tags=None, license=None, visibility=None, files=None): - """ - DatasetCreateRequest - a model defined in Swagger - """ - - self._title = None - self._description = None - self._summary = None - self._tags = None - self._license = None - self._visibility = None - self._files = None - - self.title = title - if description is not None: - self.description = description - if summary is not None: - self.summary = summary - if tags is not None: - self.tags = tags - if license is not None: - self.license = license - self.visibility = visibility - if files is not None: - self.files = files - - @property - def title(self): - """ - Gets the title of this DatasetCreateRequest. - Dataset name. - - :return: The title of this DatasetCreateRequest. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this DatasetCreateRequest. - Dataset name. - - :param title: The title of this DatasetCreateRequest. - :type: str - """ - if title is None: - raise ValueError("Invalid value for `title`, must not be `None`") - if title is not None and len(title) > 60: - raise ValueError("Invalid value for `title`, length must be less than or equal to `60`") - if title is not None and len(title) < 1: - raise ValueError("Invalid value for `title`, length must be greater than or equal to `1`") - - self._title = title - - @property - def description(self): - """ - Gets the description of this DatasetCreateRequest. - Short dataset description. - - :return: The description of this DatasetCreateRequest. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this DatasetCreateRequest. - Short dataset description. - - :param description: The description of this DatasetCreateRequest. - :type: str - """ - if description is not None and len(description) > 120: - raise ValueError("Invalid value for `description`, length must be less than or equal to `120`") - if description is not None and len(description) < 0: - raise ValueError("Invalid value for `description`, length must be greater than or equal to `0`") - - self._description = description - - @property - def summary(self): - """ - Gets the summary of this DatasetCreateRequest. - Long-form dataset summary (Markdown supported). - - :return: The summary of this DatasetCreateRequest. - :rtype: str - """ - return self._summary - - @summary.setter - def summary(self, summary): - """ - Sets the summary of this DatasetCreateRequest. - Long-form dataset summary (Markdown supported). - - :param summary: The summary of this DatasetCreateRequest. - :type: str - """ - if summary is not None and len(summary) > 25000: - raise ValueError("Invalid value for `summary`, length must be less than or equal to `25000`") - if summary is not None and len(summary) < 0: - raise ValueError("Invalid value for `summary`, length must be greater than or equal to `0`") - - self._summary = summary - - @property - def tags(self): - """ - Gets the tags of this DatasetCreateRequest. - Dataset tags. Letters numbers and spaces only (max 25 characters). - - :return: The tags of this DatasetCreateRequest. - :rtype: list[str] - """ - return self._tags - - @tags.setter - def tags(self, tags): - """ - Sets the tags of this DatasetCreateRequest. - Dataset tags. Letters numbers and spaces only (max 25 characters). - - :param tags: The tags of this DatasetCreateRequest. - :type: list[str] - """ - - self._tags = tags - - @property - def license(self): - """ - Gets the license of this DatasetCreateRequest. - Dataset license. Find additional info for allowed values [here](https://data.world/license-help). - - :return: The license of this DatasetCreateRequest. - :rtype: str - """ - return self._license - - @license.setter - def license(self, license): - """ - Sets the license of this DatasetCreateRequest. - Dataset license. Find additional info for allowed values [here](https://data.world/license-help). - - :param license: The license of this DatasetCreateRequest. - :type: str - """ - allowed_values = ["Public Domain", "PDDL", "CC-0", "CC-BY", "ODC-BY", "CC-BY-SA", "ODC-ODbL", "CC BY-NC", "CC BY-NC-SA", "Other"] - if license not in allowed_values: - raise ValueError( - "Invalid value for `license` ({0}), must be one of {1}" - .format(license, allowed_values) - ) - - self._license = license - - @property - def visibility(self): - """ - Gets the visibility of this DatasetCreateRequest. - Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. - - :return: The visibility of this DatasetCreateRequest. - :rtype: str - """ - return self._visibility - - @visibility.setter - def visibility(self, visibility): - """ - Sets the visibility of this DatasetCreateRequest. - Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. - - :param visibility: The visibility of this DatasetCreateRequest. - :type: str - """ - if visibility is None: - raise ValueError("Invalid value for `visibility`, must not be `None`") - allowed_values = ["OPEN", "PRIVATE"] - if visibility not in allowed_values: - raise ValueError( - "Invalid value for `visibility` ({0}), must be one of {1}" - .format(visibility, allowed_values) - ) - - self._visibility = visibility - - @property - def files(self): - """ - Gets the files of this DatasetCreateRequest. - Initial set of files. At dataset creation time, file uploads are not supported. However, this property can be used to add files via URL. - - :return: The files of this DatasetCreateRequest. - :rtype: list[FileCreateRequest] - """ - return self._files - - @files.setter - def files(self, files): - """ - Sets the files of this DatasetCreateRequest. - Initial set of files. At dataset creation time, file uploads are not supported. However, this property can be used to add files via URL. - - :param files: The files of this DatasetCreateRequest. - :type: list[FileCreateRequest] - """ - - self._files = files - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, DatasetCreateRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/dataset_patch_request.py b/datadotworld/client/_swagger/models/dataset_patch_request.py deleted file mode 100644 index 4da362b..0000000 --- a/datadotworld/client/_swagger/models/dataset_patch_request.py +++ /dev/null @@ -1,317 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class DatasetPatchRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'title': 'str', - 'description': 'str', - 'summary': 'str', - 'tags': 'list[str]', - 'license': 'str', - 'visibility': 'str', - 'files': 'list[FileCreateOrUpdateRequest]' - } - - attribute_map = { - 'title': 'title', - 'description': 'description', - 'summary': 'summary', - 'tags': 'tags', - 'license': 'license', - 'visibility': 'visibility', - 'files': 'files' - } - - def __init__(self, title=None, description=None, summary=None, tags=None, license=None, visibility=None, files=None): - """ - DatasetPatchRequest - a model defined in Swagger - """ - - self._title = None - self._description = None - self._summary = None - self._tags = None - self._license = None - self._visibility = None - self._files = None - - if title is not None: - self.title = title - if description is not None: - self.description = description - if summary is not None: - self.summary = summary - if tags is not None: - self.tags = tags - if license is not None: - self.license = license - if visibility is not None: - self.visibility = visibility - if files is not None: - self.files = files - - @property - def title(self): - """ - Gets the title of this DatasetPatchRequest. - Dataset name. - - :return: The title of this DatasetPatchRequest. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this DatasetPatchRequest. - Dataset name. - - :param title: The title of this DatasetPatchRequest. - :type: str - """ - if title is not None and len(title) > 60: - raise ValueError("Invalid value for `title`, length must be less than or equal to `60`") - if title is not None and len(title) < 0: - raise ValueError("Invalid value for `title`, length must be greater than or equal to `0`") - - self._title = title - - @property - def description(self): - """ - Gets the description of this DatasetPatchRequest. - Short dataset description. - - :return: The description of this DatasetPatchRequest. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this DatasetPatchRequest. - Short dataset description. - - :param description: The description of this DatasetPatchRequest. - :type: str - """ - if description is not None and len(description) > 120: - raise ValueError("Invalid value for `description`, length must be less than or equal to `120`") - if description is not None and len(description) < 0: - raise ValueError("Invalid value for `description`, length must be greater than or equal to `0`") - - self._description = description - - @property - def summary(self): - """ - Gets the summary of this DatasetPatchRequest. - Long-form dataset summary (Markdown supported). - - :return: The summary of this DatasetPatchRequest. - :rtype: str - """ - return self._summary - - @summary.setter - def summary(self, summary): - """ - Sets the summary of this DatasetPatchRequest. - Long-form dataset summary (Markdown supported). - - :param summary: The summary of this DatasetPatchRequest. - :type: str - """ - if summary is not None and len(summary) > 25000: - raise ValueError("Invalid value for `summary`, length must be less than or equal to `25000`") - if summary is not None and len(summary) < 0: - raise ValueError("Invalid value for `summary`, length must be greater than or equal to `0`") - - self._summary = summary - - @property - def tags(self): - """ - Gets the tags of this DatasetPatchRequest. - Dataset tags. Letters numbers and spaces only (max 25 characters). - - :return: The tags of this DatasetPatchRequest. - :rtype: list[str] - """ - return self._tags - - @tags.setter - def tags(self, tags): - """ - Sets the tags of this DatasetPatchRequest. - Dataset tags. Letters numbers and spaces only (max 25 characters). - - :param tags: The tags of this DatasetPatchRequest. - :type: list[str] - """ - - self._tags = tags - - @property - def license(self): - """ - Gets the license of this DatasetPatchRequest. - Dataset license. Find additional info for allowed values [here](https://data.world/license-help). - - :return: The license of this DatasetPatchRequest. - :rtype: str - """ - return self._license - - @license.setter - def license(self, license): - """ - Sets the license of this DatasetPatchRequest. - Dataset license. Find additional info for allowed values [here](https://data.world/license-help). - - :param license: The license of this DatasetPatchRequest. - :type: str - """ - allowed_values = ["Public Domain", "PDDL", "CC-0", "CC-BY", "ODC-BY", "CC-BY-SA", "ODC-ODbL", "CC BY-NC", "CC BY-NC-SA", "Other"] - if license not in allowed_values: - raise ValueError( - "Invalid value for `license` ({0}), must be one of {1}" - .format(license, allowed_values) - ) - - self._license = license - - @property - def visibility(self): - """ - Gets the visibility of this DatasetPatchRequest. - Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. - - :return: The visibility of this DatasetPatchRequest. - :rtype: str - """ - return self._visibility - - @visibility.setter - def visibility(self, visibility): - """ - Sets the visibility of this DatasetPatchRequest. - Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. - - :param visibility: The visibility of this DatasetPatchRequest. - :type: str - """ - allowed_values = ["OPEN", "PRIVATE"] - if visibility not in allowed_values: - raise ValueError( - "Invalid value for `visibility` ({0}), must be one of {1}" - .format(visibility, allowed_values) - ) - - self._visibility = visibility - - @property - def files(self): - """ - Gets the files of this DatasetPatchRequest. - Updated set of files. At dataset update time, file uploads are not supported. However, this property can be used to add files from URL or update metadata related to existing files. - - :return: The files of this DatasetPatchRequest. - :rtype: list[FileCreateOrUpdateRequest] - """ - return self._files - - @files.setter - def files(self, files): - """ - Sets the files of this DatasetPatchRequest. - Updated set of files. At dataset update time, file uploads are not supported. However, this property can be used to add files from URL or update metadata related to existing files. - - :param files: The files of this DatasetPatchRequest. - :type: list[FileCreateOrUpdateRequest] - """ - - self._files = files - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, DatasetPatchRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/dataset_put_request.py b/datadotworld/client/_swagger/models/dataset_put_request.py deleted file mode 100644 index a96f32d..0000000 --- a/datadotworld/client/_swagger/models/dataset_put_request.py +++ /dev/null @@ -1,319 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class DatasetPutRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'title': 'str', - 'description': 'str', - 'summary': 'str', - 'tags': 'list[str]', - 'license': 'str', - 'visibility': 'str', - 'files': 'list[FileCreateRequest]' - } - - attribute_map = { - 'title': 'title', - 'description': 'description', - 'summary': 'summary', - 'tags': 'tags', - 'license': 'license', - 'visibility': 'visibility', - 'files': 'files' - } - - def __init__(self, title=None, description=None, summary=None, tags=None, license=None, visibility=None, files=None): - """ - DatasetPutRequest - a model defined in Swagger - """ - - self._title = None - self._description = None - self._summary = None - self._tags = None - self._license = None - self._visibility = None - self._files = None - - self.title = title - if description is not None: - self.description = description - if summary is not None: - self.summary = summary - if tags is not None: - self.tags = tags - if license is not None: - self.license = license - self.visibility = visibility - if files is not None: - self.files = files - - @property - def title(self): - """ - Gets the title of this DatasetPutRequest. - Dataset name. - - :return: The title of this DatasetPutRequest. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this DatasetPutRequest. - Dataset name. - - :param title: The title of this DatasetPutRequest. - :type: str - """ - if title is None: - raise ValueError("Invalid value for `title`, must not be `None`") - if title is not None and len(title) > 60: - raise ValueError("Invalid value for `title`, length must be less than or equal to `60`") - if title is not None and len(title) < 1: - raise ValueError("Invalid value for `title`, length must be greater than or equal to `1`") - - self._title = title - - @property - def description(self): - """ - Gets the description of this DatasetPutRequest. - Short dataset description. - - :return: The description of this DatasetPutRequest. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this DatasetPutRequest. - Short dataset description. - - :param description: The description of this DatasetPutRequest. - :type: str - """ - if description is not None and len(description) > 120: - raise ValueError("Invalid value for `description`, length must be less than or equal to `120`") - if description is not None and len(description) < 0: - raise ValueError("Invalid value for `description`, length must be greater than or equal to `0`") - - self._description = description - - @property - def summary(self): - """ - Gets the summary of this DatasetPutRequest. - Long-form dataset summary (Markdown supported). - - :return: The summary of this DatasetPutRequest. - :rtype: str - """ - return self._summary - - @summary.setter - def summary(self, summary): - """ - Sets the summary of this DatasetPutRequest. - Long-form dataset summary (Markdown supported). - - :param summary: The summary of this DatasetPutRequest. - :type: str - """ - if summary is not None and len(summary) > 25000: - raise ValueError("Invalid value for `summary`, length must be less than or equal to `25000`") - if summary is not None and len(summary) < 0: - raise ValueError("Invalid value for `summary`, length must be greater than or equal to `0`") - - self._summary = summary - - @property - def tags(self): - """ - Gets the tags of this DatasetPutRequest. - Dataset tags. Letters numbers and spaces only (max 25 characters). - - :return: The tags of this DatasetPutRequest. - :rtype: list[str] - """ - return self._tags - - @tags.setter - def tags(self, tags): - """ - Sets the tags of this DatasetPutRequest. - Dataset tags. Letters numbers and spaces only (max 25 characters). - - :param tags: The tags of this DatasetPutRequest. - :type: list[str] - """ - - self._tags = tags - - @property - def license(self): - """ - Gets the license of this DatasetPutRequest. - Dataset license. Find additional info for allowed values [here](https://data.world/license-help). - - :return: The license of this DatasetPutRequest. - :rtype: str - """ - return self._license - - @license.setter - def license(self, license): - """ - Sets the license of this DatasetPutRequest. - Dataset license. Find additional info for allowed values [here](https://data.world/license-help). - - :param license: The license of this DatasetPutRequest. - :type: str - """ - allowed_values = ["Public Domain", "PDDL", "CC-0", "CC-BY", "ODC-BY", "CC-BY-SA", "ODC-ODbL", "CC BY-NC", "CC BY-NC-SA", "Other"] - if license not in allowed_values: - raise ValueError( - "Invalid value for `license` ({0}), must be one of {1}" - .format(license, allowed_values) - ) - - self._license = license - - @property - def visibility(self): - """ - Gets the visibility of this DatasetPutRequest. - Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. - - :return: The visibility of this DatasetPutRequest. - :rtype: str - """ - return self._visibility - - @visibility.setter - def visibility(self, visibility): - """ - Sets the visibility of this DatasetPutRequest. - Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. - - :param visibility: The visibility of this DatasetPutRequest. - :type: str - """ - if visibility is None: - raise ValueError("Invalid value for `visibility`, must not be `None`") - allowed_values = ["OPEN", "PRIVATE"] - if visibility not in allowed_values: - raise ValueError( - "Invalid value for `visibility` ({0}), must be one of {1}" - .format(visibility, allowed_values) - ) - - self._visibility = visibility - - @property - def files(self): - """ - Gets the files of this DatasetPutRequest. - Initial set of files. At dataset creation time, file uploads are not supported. However, this property can be used to add files via URL. - - :return: The files of this DatasetPutRequest. - :rtype: list[FileCreateRequest] - """ - return self._files - - @files.setter - def files(self, files): - """ - Sets the files of this DatasetPutRequest. - Initial set of files. At dataset creation time, file uploads are not supported. However, this property can be used to add files via URL. - - :param files: The files of this DatasetPutRequest. - :type: list[FileCreateRequest] - """ - - self._files = files - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, DatasetPutRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/dataset_summary_response.py b/datadotworld/client/_swagger/models/dataset_summary_response.py deleted file mode 100644 index 8cc3adc..0000000 --- a/datadotworld/client/_swagger/models/dataset_summary_response.py +++ /dev/null @@ -1,498 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class DatasetSummaryResponse(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'owner': 'str', - 'id': 'str', - 'title': 'str', - 'description': 'str', - 'summary': 'str', - 'tags': 'list[str]', - 'license': 'str', - 'visibility': 'str', - 'files': 'list[FileSummaryResponse]', - 'status': 'str', - 'created': 'str', - 'updated': 'str', - 'is_project': 'bool', - 'access_level': 'str' - } - - attribute_map = { - 'owner': 'owner', - 'id': 'id', - 'title': 'title', - 'description': 'description', - 'summary': 'summary', - 'tags': 'tags', - 'license': 'license', - 'visibility': 'visibility', - 'files': 'files', - 'status': 'status', - 'created': 'created', - 'updated': 'updated', - 'is_project': 'isProject', - 'access_level': 'accessLevel' - } - - def __init__(self, owner=None, id=None, title=None, description=None, summary=None, tags=None, license=None, visibility=None, files=None, status=None, created=None, updated=None, is_project=None, access_level=None): - """ - DatasetSummaryResponse - a model defined in Swagger - """ - - self._owner = None - self._id = None - self._title = None - self._description = None - self._summary = None - self._tags = None - self._license = None - self._visibility = None - self._files = None - self._status = None - self._created = None - self._updated = None - self._is_project = None - self._access_level = None - - self.owner = owner - self.id = id - self.title = title - if description is not None: - self.description = description - if summary is not None: - self.summary = summary - if tags is not None: - self.tags = tags - if license is not None: - self.license = license - self.visibility = visibility - if files is not None: - self.files = files - self.status = status - self.created = created - self.updated = updated - self.is_project = is_project - self.access_level = access_level - - @property - def owner(self): - """ - Gets the owner of this DatasetSummaryResponse. - User name and unique identifier of the creator of the dataset. - - :return: The owner of this DatasetSummaryResponse. - :rtype: str - """ - return self._owner - - @owner.setter - def owner(self, owner): - """ - Sets the owner of this DatasetSummaryResponse. - User name and unique identifier of the creator of the dataset. - - :param owner: The owner of this DatasetSummaryResponse. - :type: str - """ - if owner is None: - raise ValueError("Invalid value for `owner`, must not be `None`") - - self._owner = owner - - @property - def id(self): - """ - Gets the id of this DatasetSummaryResponse. - Unique identifier of dataset. - - :return: The id of this DatasetSummaryResponse. - :rtype: str - """ - return self._id - - @id.setter - def id(self, id): - """ - Sets the id of this DatasetSummaryResponse. - Unique identifier of dataset. - - :param id: The id of this DatasetSummaryResponse. - :type: str - """ - if id is None: - raise ValueError("Invalid value for `id`, must not be `None`") - - self._id = id - - @property - def title(self): - """ - Gets the title of this DatasetSummaryResponse. - Dataset name. - - :return: The title of this DatasetSummaryResponse. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this DatasetSummaryResponse. - Dataset name. - - :param title: The title of this DatasetSummaryResponse. - :type: str - """ - if title is None: - raise ValueError("Invalid value for `title`, must not be `None`") - - self._title = title - - @property - def description(self): - """ - Gets the description of this DatasetSummaryResponse. - Short dataset description. - - :return: The description of this DatasetSummaryResponse. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this DatasetSummaryResponse. - Short dataset description. - - :param description: The description of this DatasetSummaryResponse. - :type: str - """ - - self._description = description - - @property - def summary(self): - """ - Gets the summary of this DatasetSummaryResponse. - Long-form dataset summary (Markdown supported). - - :return: The summary of this DatasetSummaryResponse. - :rtype: str - """ - return self._summary - - @summary.setter - def summary(self, summary): - """ - Sets the summary of this DatasetSummaryResponse. - Long-form dataset summary (Markdown supported). - - :param summary: The summary of this DatasetSummaryResponse. - :type: str - """ - - self._summary = summary - - @property - def tags(self): - """ - Gets the tags of this DatasetSummaryResponse. - Dataset tags. Letters numbers and spaces only (max 25 characters). - - :return: The tags of this DatasetSummaryResponse. - :rtype: list[str] - """ - return self._tags - - @tags.setter - def tags(self, tags): - """ - Sets the tags of this DatasetSummaryResponse. - Dataset tags. Letters numbers and spaces only (max 25 characters). - - :param tags: The tags of this DatasetSummaryResponse. - :type: list[str] - """ - - self._tags = tags - - @property - def license(self): - """ - Gets the license of this DatasetSummaryResponse. - Dataset license. Find additional info for allowed values [here](https://data.world/license-help). - - :return: The license of this DatasetSummaryResponse. - :rtype: str - """ - return self._license - - @license.setter - def license(self, license): - """ - Sets the license of this DatasetSummaryResponse. - Dataset license. Find additional info for allowed values [here](https://data.world/license-help). - - :param license: The license of this DatasetSummaryResponse. - :type: str - """ - - self._license = license - - @property - def visibility(self): - """ - Gets the visibility of this DatasetSummaryResponse. - Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. - - :return: The visibility of this DatasetSummaryResponse. - :rtype: str - """ - return self._visibility - - @visibility.setter - def visibility(self, visibility): - """ - Sets the visibility of this DatasetSummaryResponse. - Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. - - :param visibility: The visibility of this DatasetSummaryResponse. - :type: str - """ - if visibility is None: - raise ValueError("Invalid value for `visibility`, must not be `None`") - - self._visibility = visibility - - @property - def files(self): - """ - Gets the files of this DatasetSummaryResponse. - Initial set of files. At dataset creation time, file uploads are not supported. However, this property can be used to add files via URL. - - :return: The files of this DatasetSummaryResponse. - :rtype: list[FileSummaryResponse] - """ - return self._files - - @files.setter - def files(self, files): - """ - Sets the files of this DatasetSummaryResponse. - Initial set of files. At dataset creation time, file uploads are not supported. However, this property can be used to add files via URL. - - :param files: The files of this DatasetSummaryResponse. - :type: list[FileSummaryResponse] - """ - - self._files = files - - @property - def status(self): - """ - Gets the status of this DatasetSummaryResponse. - Processing status of dataset. This status can be checked periodically after changes are made to the dataset to determine the status of asynchronous processing. * `NEW`: Just created. Not yet processed. * `INPROGRESS`: Currently being processed. * `LOADED`: Successfully processed. * `SYSTEMERROR`: Error state due to processing failure. - - :return: The status of this DatasetSummaryResponse. - :rtype: str - """ - return self._status - - @status.setter - def status(self, status): - """ - Sets the status of this DatasetSummaryResponse. - Processing status of dataset. This status can be checked periodically after changes are made to the dataset to determine the status of asynchronous processing. * `NEW`: Just created. Not yet processed. * `INPROGRESS`: Currently being processed. * `LOADED`: Successfully processed. * `SYSTEMERROR`: Error state due to processing failure. - - :param status: The status of this DatasetSummaryResponse. - :type: str - """ - if status is None: - raise ValueError("Invalid value for `status`, must not be `None`") - - self._status = status - - @property - def created(self): - """ - Gets the created of this DatasetSummaryResponse. - Date and time when the dataset was created. - - :return: The created of this DatasetSummaryResponse. - :rtype: str - """ - return self._created - - @created.setter - def created(self, created): - """ - Sets the created of this DatasetSummaryResponse. - Date and time when the dataset was created. - - :param created: The created of this DatasetSummaryResponse. - :type: str - """ - if created is None: - raise ValueError("Invalid value for `created`, must not be `None`") - - self._created = created - - @property - def updated(self): - """ - Gets the updated of this DatasetSummaryResponse. - Date and time when the dataset was last updated. - - :return: The updated of this DatasetSummaryResponse. - :rtype: str - """ - return self._updated - - @updated.setter - def updated(self, updated): - """ - Sets the updated of this DatasetSummaryResponse. - Date and time when the dataset was last updated. - - :param updated: The updated of this DatasetSummaryResponse. - :type: str - """ - if updated is None: - raise ValueError("Invalid value for `updated`, must not be `None`") - - self._updated = updated - - @property - def is_project(self): - """ - Gets the is_project of this DatasetSummaryResponse. - Every data project on data.world comes with a default dataset linked to it. This flag indicates if the dataset is a project's default dataset. - - :return: The is_project of this DatasetSummaryResponse. - :rtype: bool - """ - return self._is_project - - @is_project.setter - def is_project(self, is_project): - """ - Sets the is_project of this DatasetSummaryResponse. - Every data project on data.world comes with a default dataset linked to it. This flag indicates if the dataset is a project's default dataset. - - :param is_project: The is_project of this DatasetSummaryResponse. - :type: bool - """ - if is_project is None: - raise ValueError("Invalid value for `is_project`, must not be `None`") - - self._is_project = is_project - - @property - def access_level(self): - """ - Gets the access_level of this DatasetSummaryResponse. - The level of access the authenticated user is allowed with respect to dataset: * `NONE` Not allowed any access. * `READ` Allowed to know that the dataset exists, view and download data and metadata. * `WRITE` Allowed to update data and metadata, in addition to what READ allows. * `ADMIN` Allowed to delete dataset, in addition to what WRITE allows. - - :return: The access_level of this DatasetSummaryResponse. - :rtype: str - """ - return self._access_level - - @access_level.setter - def access_level(self, access_level): - """ - Sets the access_level of this DatasetSummaryResponse. - The level of access the authenticated user is allowed with respect to dataset: * `NONE` Not allowed any access. * `READ` Allowed to know that the dataset exists, view and download data and metadata. * `WRITE` Allowed to update data and metadata, in addition to what READ allows. * `ADMIN` Allowed to delete dataset, in addition to what WRITE allows. - - :param access_level: The access_level of this DatasetSummaryResponse. - :type: str - """ - if access_level is None: - raise ValueError("Invalid value for `access_level`, must not be `None`") - - self._access_level = access_level - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, DatasetSummaryResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/error_message.py b/datadotworld/client/_swagger/models/error_message.py deleted file mode 100644 index 07f3b9d..0000000 --- a/datadotworld/client/_swagger/models/error_message.py +++ /dev/null @@ -1,181 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class ErrorMessage(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'code': 'int', - 'message': 'str', - 'details': 'str' - } - - attribute_map = { - 'code': 'code', - 'message': 'message', - 'details': 'details' - } - - def __init__(self, code=None, message=None, details=None): - """ - ErrorMessage - a model defined in Swagger - """ - - self._code = None - self._message = None - self._details = None - - if code is not None: - self.code = code - if message is not None: - self.message = message - if details is not None: - self.details = details - - @property - def code(self): - """ - Gets the code of this ErrorMessage. - HTTP Error Code - - :return: The code of this ErrorMessage. - :rtype: int - """ - return self._code - - @code.setter - def code(self, code): - """ - Sets the code of this ErrorMessage. - HTTP Error Code - - :param code: The code of this ErrorMessage. - :type: int - """ - - self._code = code - - @property - def message(self): - """ - Gets the message of this ErrorMessage. - Human-readable error message. - - :return: The message of this ErrorMessage. - :rtype: str - """ - return self._message - - @message.setter - def message(self, message): - """ - Sets the message of this ErrorMessage. - Human-readable error message. - - :param message: The message of this ErrorMessage. - :type: str - """ - - self._message = message - - @property - def details(self): - """ - Gets the details of this ErrorMessage. - Underlying error cause. - - :return: The details of this ErrorMessage. - :rtype: str - """ - return self._details - - @details.setter - def details(self, details): - """ - Sets the details of this ErrorMessage. - Underlying error cause. - - :param details: The details of this ErrorMessage. - :type: str - """ - - self._details = details - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, ErrorMessage): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/file_batch_update_request.py b/datadotworld/client/_swagger/models/file_batch_update_request.py deleted file mode 100644 index 6164cab..0000000 --- a/datadotworld/client/_swagger/models/file_batch_update_request.py +++ /dev/null @@ -1,125 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class FileBatchUpdateRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'files': 'list[FileCreateOrUpdateRequest]' - } - - attribute_map = { - 'files': 'files' - } - - def __init__(self, files=None): - """ - FileBatchUpdateRequest - a model defined in Swagger - """ - - self._files = None - - if files is not None: - self.files = files - - @property - def files(self): - """ - Gets the files of this FileBatchUpdateRequest. - Updated set of files. When updating a set of files, file uploads are not supported. However, this property can be used to add files via URL or update metadata related to existing files. - - :return: The files of this FileBatchUpdateRequest. - :rtype: list[FileCreateOrUpdateRequest] - """ - return self._files - - @files.setter - def files(self, files): - """ - Sets the files of this FileBatchUpdateRequest. - Updated set of files. When updating a set of files, file uploads are not supported. However, this property can be used to add files via URL or update metadata related to existing files. - - :param files: The files of this FileBatchUpdateRequest. - :type: list[FileCreateOrUpdateRequest] - """ - - self._files = files - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, FileBatchUpdateRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/file_create_or_update_request.py b/datadotworld/client/_swagger/models/file_create_or_update_request.py deleted file mode 100644 index 7f5dd03..0000000 --- a/datadotworld/client/_swagger/models/file_create_or_update_request.py +++ /dev/null @@ -1,225 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class FileCreateOrUpdateRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'name': 'str', - 'source': 'FileSourceCreateOrUpdateRequest', - 'description': 'str', - 'labels': 'list[str]' - } - - attribute_map = { - 'name': 'name', - 'source': 'source', - 'description': 'description', - 'labels': 'labels' - } - - def __init__(self, name=None, source=None, description=None, labels=None): - """ - FileCreateOrUpdateRequest - a model defined in Swagger - """ - - self._name = None - self._source = None - self._description = None - self._labels = None - - self.name = name - if source is not None: - self.source = source - if description is not None: - self.description = description - if labels is not None: - self.labels = labels - - @property - def name(self): - """ - Gets the name of this FileCreateOrUpdateRequest. - File name. Should include type extension always when possible. Must not include slashes. - - :return: The name of this FileCreateOrUpdateRequest. - :rtype: str - """ - return self._name - - @name.setter - def name(self, name): - """ - Sets the name of this FileCreateOrUpdateRequest. - File name. Should include type extension always when possible. Must not include slashes. - - :param name: The name of this FileCreateOrUpdateRequest. - :type: str - """ - if name is None: - raise ValueError("Invalid value for `name`, must not be `None`") - if name is not None and len(name) > 128: - raise ValueError("Invalid value for `name`, length must be less than or equal to `128`") - if name is not None and len(name) < 1: - raise ValueError("Invalid value for `name`, length must be greater than or equal to `1`") - if name is not None and not re.search('^[^\/]+$', name): - raise ValueError("Invalid value for `name`, must be a follow pattern or equal to `/^[^\/]+$/`") - - self._name = name - - @property - def source(self): - """ - Gets the source of this FileCreateOrUpdateRequest. - - :return: The source of this FileCreateOrUpdateRequest. - :rtype: FileSourceCreateOrUpdateRequest - """ - return self._source - - @source.setter - def source(self, source): - """ - Sets the source of this FileCreateOrUpdateRequest. - - :param source: The source of this FileCreateOrUpdateRequest. - :type: FileSourceCreateOrUpdateRequest - """ - - self._source = source - - @property - def description(self): - """ - Gets the description of this FileCreateOrUpdateRequest. - File description. - - :return: The description of this FileCreateOrUpdateRequest. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this FileCreateOrUpdateRequest. - File description. - - :param description: The description of this FileCreateOrUpdateRequest. - :type: str - """ - if description is not None and len(description) > 240: - raise ValueError("Invalid value for `description`, length must be less than or equal to `240`") - if description is not None and len(description) < 1: - raise ValueError("Invalid value for `description`, length must be greater than or equal to `1`") - - self._description = description - - @property - def labels(self): - """ - Gets the labels of this FileCreateOrUpdateRequest. - File labels. - - :return: The labels of this FileCreateOrUpdateRequest. - :rtype: list[str] - """ - return self._labels - - @labels.setter - def labels(self, labels): - """ - Sets the labels of this FileCreateOrUpdateRequest. - File labels. - - :param labels: The labels of this FileCreateOrUpdateRequest. - :type: list[str] - """ - allowed_values = ["raw data", "documentation", "visualization", "clean data", "script", "report"] - if not set(labels).issubset(set(allowed_values)): - raise ValueError( - "Invalid values for `labels` [{0}], must be a subset of [{1}]" - .format(", ".join(map(str, set(labels)-set(allowed_values))), - ", ".join(map(str, allowed_values))) - ) - - self._labels = labels - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, FileCreateOrUpdateRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/file_create_request.py b/datadotworld/client/_swagger/models/file_create_request.py deleted file mode 100644 index a9ae931..0000000 --- a/datadotworld/client/_swagger/models/file_create_request.py +++ /dev/null @@ -1,226 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class FileCreateRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'name': 'str', - 'source': 'FileSourceCreateRequest', - 'description': 'str', - 'labels': 'list[str]' - } - - attribute_map = { - 'name': 'name', - 'source': 'source', - 'description': 'description', - 'labels': 'labels' - } - - def __init__(self, name=None, source=None, description=None, labels=None): - """ - FileCreateRequest - a model defined in Swagger - """ - - self._name = None - self._source = None - self._description = None - self._labels = None - - self.name = name - self.source = source - if description is not None: - self.description = description - if labels is not None: - self.labels = labels - - @property - def name(self): - """ - Gets the name of this FileCreateRequest. - File name. Should include type extension always when possible. Must not include slashes. - - :return: The name of this FileCreateRequest. - :rtype: str - """ - return self._name - - @name.setter - def name(self, name): - """ - Sets the name of this FileCreateRequest. - File name. Should include type extension always when possible. Must not include slashes. - - :param name: The name of this FileCreateRequest. - :type: str - """ - if name is None: - raise ValueError("Invalid value for `name`, must not be `None`") - if name is not None and len(name) > 128: - raise ValueError("Invalid value for `name`, length must be less than or equal to `128`") - if name is not None and len(name) < 1: - raise ValueError("Invalid value for `name`, length must be greater than or equal to `1`") - if name is not None and not re.search('^[^\/]+$', name): - raise ValueError("Invalid value for `name`, must be a follow pattern or equal to `/^[^\/]+$/`") - - self._name = name - - @property - def source(self): - """ - Gets the source of this FileCreateRequest. - - :return: The source of this FileCreateRequest. - :rtype: FileSourceCreateRequest - """ - return self._source - - @source.setter - def source(self, source): - """ - Sets the source of this FileCreateRequest. - - :param source: The source of this FileCreateRequest. - :type: FileSourceCreateRequest - """ - if source is None: - raise ValueError("Invalid value for `source`, must not be `None`") - - self._source = source - - @property - def description(self): - """ - Gets the description of this FileCreateRequest. - File description. - - :return: The description of this FileCreateRequest. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this FileCreateRequest. - File description. - - :param description: The description of this FileCreateRequest. - :type: str - """ - if description is not None and len(description) > 240: - raise ValueError("Invalid value for `description`, length must be less than or equal to `240`") - if description is not None and len(description) < 1: - raise ValueError("Invalid value for `description`, length must be greater than or equal to `1`") - - self._description = description - - @property - def labels(self): - """ - Gets the labels of this FileCreateRequest. - File labels. - - :return: The labels of this FileCreateRequest. - :rtype: list[str] - """ - return self._labels - - @labels.setter - def labels(self, labels): - """ - Sets the labels of this FileCreateRequest. - File labels. - - :param labels: The labels of this FileCreateRequest. - :type: list[str] - """ - allowed_values = ["raw data", "documentation", "visualization", "clean data", "script", "report"] - if not set(labels).issubset(set(allowed_values)): - raise ValueError( - "Invalid values for `labels` [{0}], must be a subset of [{1}]" - .format(", ".join(map(str, set(labels)-set(allowed_values))), - ", ".join(map(str, allowed_values))) - ) - - self._labels = labels - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, FileCreateRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/file_source_create_or_update_request.py b/datadotworld/client/_swagger/models/file_source_create_or_update_request.py deleted file mode 100644 index a62534c..0000000 --- a/datadotworld/client/_swagger/models/file_source_create_or_update_request.py +++ /dev/null @@ -1,327 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class FileSourceCreateOrUpdateRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'url': 'str', - 'method': 'str', - 'request_headers': 'dict(str, str)', - 'request_entity': 'str', - 'oauth_token': 'OauthTokenReference', - 'credentials': 'WebCredentials', - 'authorization': 'WebAuthorization', - 'expand_archive': 'bool' - } - - attribute_map = { - 'url': 'url', - 'method': 'method', - 'request_headers': 'requestHeaders', - 'request_entity': 'requestEntity', - 'oauth_token': 'oauthToken', - 'credentials': 'credentials', - 'authorization': 'authorization', - 'expand_archive': 'expandArchive' - } - - def __init__(self, url=None, method='GET', request_headers=None, request_entity=None, oauth_token=None, credentials=None, authorization=None, expand_archive=False): - """ - FileSourceCreateOrUpdateRequest - a model defined in Swagger - """ - - self._url = None - self._method = None - self._request_headers = None - self._request_entity = None - self._oauth_token = None - self._credentials = None - self._authorization = None - self._expand_archive = None - - self.url = url - self.method = method - if request_headers is not None: - self.request_headers = request_headers - if request_entity is not None: - self.request_entity = request_entity - if oauth_token is not None: - self.oauth_token = oauth_token - if credentials is not None: - self.credentials = credentials - if authorization is not None: - self.authorization = authorization - if expand_archive is not None: - self.expand_archive = expand_archive - - @property - def url(self): - """ - Gets the url of this FileSourceCreateOrUpdateRequest. - Source URL of file. Must be an http, https, or stream URL. - - :return: The url of this FileSourceCreateOrUpdateRequest. - :rtype: str - """ - return self._url - - @url.setter - def url(self, url): - """ - Sets the url of this FileSourceCreateOrUpdateRequest. - Source URL of file. Must be an http, https, or stream URL. - - :param url: The url of this FileSourceCreateOrUpdateRequest. - :type: str - """ - if url is None: - raise ValueError("Invalid value for `url`, must not be `None`") - if url is not None and len(url) > 4096: - raise ValueError("Invalid value for `url`, length must be less than or equal to `4096`") - if url is not None and len(url) < 1: - raise ValueError("Invalid value for `url`, length must be greater than or equal to `1`") - if url is not None and not re.search('^(https?|stream):.*', url): - raise ValueError("Invalid value for `url`, must be a follow pattern or equal to `/^(https?|stream):.*/`") - - self._url = url - - @property - def method(self): - """ - Gets the method of this FileSourceCreateOrUpdateRequest. - - :return: The method of this FileSourceCreateOrUpdateRequest. - :rtype: str - """ - return self._method - - @method.setter - def method(self, method): - """ - Sets the method of this FileSourceCreateOrUpdateRequest. - - :param method: The method of this FileSourceCreateOrUpdateRequest. - :type: str - """ - if method is None: - raise ValueError("Invalid value for `method`, must not be `None`") - allowed_values = ["GET", "POST"] - if method not in allowed_values: - raise ValueError( - "Invalid value for `method` ({0}), must be one of {1}" - .format(method, allowed_values) - ) - - self._method = method - - @property - def request_headers(self): - """ - Gets the request_headers of this FileSourceCreateOrUpdateRequest. - A map of custom HTTP header name/value pairs to pass with the request. If a `requestEntity` string is specified, this must contain a `Content-Type` header. An `Authorization` header value will be converted to a `WebAuthorization` object and the credentials will be encrypted. The total size of the url and custom headers must not exceed 4096 bytes in the HTTP request, including whitespace, colons and CRLF characters. - - :return: The request_headers of this FileSourceCreateOrUpdateRequest. - :rtype: dict(str, str) - """ - return self._request_headers - - @request_headers.setter - def request_headers(self, request_headers): - """ - Sets the request_headers of this FileSourceCreateOrUpdateRequest. - A map of custom HTTP header name/value pairs to pass with the request. If a `requestEntity` string is specified, this must contain a `Content-Type` header. An `Authorization` header value will be converted to a `WebAuthorization` object and the credentials will be encrypted. The total size of the url and custom headers must not exceed 4096 bytes in the HTTP request, including whitespace, colons and CRLF characters. - - :param request_headers: The request_headers of this FileSourceCreateOrUpdateRequest. - :type: dict(str, str) - """ - - self._request_headers = request_headers - - @property - def request_entity(self): - """ - Gets the request_entity of this FileSourceCreateOrUpdateRequest. - - :return: The request_entity of this FileSourceCreateOrUpdateRequest. - :rtype: str - """ - return self._request_entity - - @request_entity.setter - def request_entity(self, request_entity): - """ - Sets the request_entity of this FileSourceCreateOrUpdateRequest. - - :param request_entity: The request_entity of this FileSourceCreateOrUpdateRequest. - :type: str - """ - if request_entity is not None and len(request_entity) > 10000: - raise ValueError("Invalid value for `request_entity`, length must be less than or equal to `10000`") - - self._request_entity = request_entity - - @property - def oauth_token(self): - """ - Gets the oauth_token of this FileSourceCreateOrUpdateRequest. - - :return: The oauth_token of this FileSourceCreateOrUpdateRequest. - :rtype: OauthTokenReference - """ - return self._oauth_token - - @oauth_token.setter - def oauth_token(self, oauth_token): - """ - Sets the oauth_token of this FileSourceCreateOrUpdateRequest. - - :param oauth_token: The oauth_token of this FileSourceCreateOrUpdateRequest. - :type: OauthTokenReference - """ - - self._oauth_token = oauth_token - - @property - def credentials(self): - """ - Gets the credentials of this FileSourceCreateOrUpdateRequest. - - :return: The credentials of this FileSourceCreateOrUpdateRequest. - :rtype: WebCredentials - """ - return self._credentials - - @credentials.setter - def credentials(self, credentials): - """ - Sets the credentials of this FileSourceCreateOrUpdateRequest. - - :param credentials: The credentials of this FileSourceCreateOrUpdateRequest. - :type: WebCredentials - """ - - self._credentials = credentials - - @property - def authorization(self): - """ - Gets the authorization of this FileSourceCreateOrUpdateRequest. - - :return: The authorization of this FileSourceCreateOrUpdateRequest. - :rtype: WebAuthorization - """ - return self._authorization - - @authorization.setter - def authorization(self, authorization): - """ - Sets the authorization of this FileSourceCreateOrUpdateRequest. - - :param authorization: The authorization of this FileSourceCreateOrUpdateRequest. - :type: WebAuthorization - """ - - self._authorization = authorization - - @property - def expand_archive(self): - """ - Gets the expand_archive of this FileSourceCreateOrUpdateRequest. - Indicates whether compressed files should be expanded upon upload. - - :return: The expand_archive of this FileSourceCreateOrUpdateRequest. - :rtype: bool - """ - return self._expand_archive - - @expand_archive.setter - def expand_archive(self, expand_archive): - """ - Sets the expand_archive of this FileSourceCreateOrUpdateRequest. - Indicates whether compressed files should be expanded upon upload. - - :param expand_archive: The expand_archive of this FileSourceCreateOrUpdateRequest. - :type: bool - """ - - self._expand_archive = expand_archive - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, FileSourceCreateOrUpdateRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/file_source_create_request.py b/datadotworld/client/_swagger/models/file_source_create_request.py deleted file mode 100644 index 765549f..0000000 --- a/datadotworld/client/_swagger/models/file_source_create_request.py +++ /dev/null @@ -1,327 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class FileSourceCreateRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'url': 'str', - 'method': 'str', - 'request_headers': 'dict(str, str)', - 'request_entity': 'str', - 'oauth_token': 'OauthTokenReference', - 'credentials': 'WebCredentials', - 'authorization': 'WebAuthorization', - 'expand_archive': 'bool' - } - - attribute_map = { - 'url': 'url', - 'method': 'method', - 'request_headers': 'requestHeaders', - 'request_entity': 'requestEntity', - 'oauth_token': 'oauthToken', - 'credentials': 'credentials', - 'authorization': 'authorization', - 'expand_archive': 'expandArchive' - } - - def __init__(self, url=None, method='GET', request_headers=None, request_entity=None, oauth_token=None, credentials=None, authorization=None, expand_archive=False): - """ - FileSourceCreateRequest - a model defined in Swagger - """ - - self._url = None - self._method = None - self._request_headers = None - self._request_entity = None - self._oauth_token = None - self._credentials = None - self._authorization = None - self._expand_archive = None - - self.url = url - self.method = method - if request_headers is not None: - self.request_headers = request_headers - if request_entity is not None: - self.request_entity = request_entity - if oauth_token is not None: - self.oauth_token = oauth_token - if credentials is not None: - self.credentials = credentials - if authorization is not None: - self.authorization = authorization - if expand_archive is not None: - self.expand_archive = expand_archive - - @property - def url(self): - """ - Gets the url of this FileSourceCreateRequest. - Source URL of file. Must be an http, https. - - :return: The url of this FileSourceCreateRequest. - :rtype: str - """ - return self._url - - @url.setter - def url(self, url): - """ - Sets the url of this FileSourceCreateRequest. - Source URL of file. Must be an http, https. - - :param url: The url of this FileSourceCreateRequest. - :type: str - """ - if url is None: - raise ValueError("Invalid value for `url`, must not be `None`") - if url is not None and len(url) > 4096: - raise ValueError("Invalid value for `url`, length must be less than or equal to `4096`") - if url is not None and len(url) < 1: - raise ValueError("Invalid value for `url`, length must be greater than or equal to `1`") - if url is not None and not re.search('^https?:.*', url): - raise ValueError("Invalid value for `url`, must be a follow pattern or equal to `/^https?:.*/`") - - self._url = url - - @property - def method(self): - """ - Gets the method of this FileSourceCreateRequest. - - :return: The method of this FileSourceCreateRequest. - :rtype: str - """ - return self._method - - @method.setter - def method(self, method): - """ - Sets the method of this FileSourceCreateRequest. - - :param method: The method of this FileSourceCreateRequest. - :type: str - """ - if method is None: - raise ValueError("Invalid value for `method`, must not be `None`") - allowed_values = ["GET", "POST"] - if method not in allowed_values: - raise ValueError( - "Invalid value for `method` ({0}), must be one of {1}" - .format(method, allowed_values) - ) - - self._method = method - - @property - def request_headers(self): - """ - Gets the request_headers of this FileSourceCreateRequest. - A map of custom HTTP header name/value pairs to pass with the request. If a `requestEntity` string is specified, this must contain a `Content-Type` header. An `Authorization` header value will be converted to a `WebAuthorization` object and the credentials will be encrypted. The total size of the url and custom headers must not exceed 4096 bytes in the HTTP request, including whitespace, colons and CRLF characters. - - :return: The request_headers of this FileSourceCreateRequest. - :rtype: dict(str, str) - """ - return self._request_headers - - @request_headers.setter - def request_headers(self, request_headers): - """ - Sets the request_headers of this FileSourceCreateRequest. - A map of custom HTTP header name/value pairs to pass with the request. If a `requestEntity` string is specified, this must contain a `Content-Type` header. An `Authorization` header value will be converted to a `WebAuthorization` object and the credentials will be encrypted. The total size of the url and custom headers must not exceed 4096 bytes in the HTTP request, including whitespace, colons and CRLF characters. - - :param request_headers: The request_headers of this FileSourceCreateRequest. - :type: dict(str, str) - """ - - self._request_headers = request_headers - - @property - def request_entity(self): - """ - Gets the request_entity of this FileSourceCreateRequest. - - :return: The request_entity of this FileSourceCreateRequest. - :rtype: str - """ - return self._request_entity - - @request_entity.setter - def request_entity(self, request_entity): - """ - Sets the request_entity of this FileSourceCreateRequest. - - :param request_entity: The request_entity of this FileSourceCreateRequest. - :type: str - """ - if request_entity is not None and len(request_entity) > 10000: - raise ValueError("Invalid value for `request_entity`, length must be less than or equal to `10000`") - - self._request_entity = request_entity - - @property - def oauth_token(self): - """ - Gets the oauth_token of this FileSourceCreateRequest. - - :return: The oauth_token of this FileSourceCreateRequest. - :rtype: OauthTokenReference - """ - return self._oauth_token - - @oauth_token.setter - def oauth_token(self, oauth_token): - """ - Sets the oauth_token of this FileSourceCreateRequest. - - :param oauth_token: The oauth_token of this FileSourceCreateRequest. - :type: OauthTokenReference - """ - - self._oauth_token = oauth_token - - @property - def credentials(self): - """ - Gets the credentials of this FileSourceCreateRequest. - - :return: The credentials of this FileSourceCreateRequest. - :rtype: WebCredentials - """ - return self._credentials - - @credentials.setter - def credentials(self, credentials): - """ - Sets the credentials of this FileSourceCreateRequest. - - :param credentials: The credentials of this FileSourceCreateRequest. - :type: WebCredentials - """ - - self._credentials = credentials - - @property - def authorization(self): - """ - Gets the authorization of this FileSourceCreateRequest. - - :return: The authorization of this FileSourceCreateRequest. - :rtype: WebAuthorization - """ - return self._authorization - - @authorization.setter - def authorization(self, authorization): - """ - Sets the authorization of this FileSourceCreateRequest. - - :param authorization: The authorization of this FileSourceCreateRequest. - :type: WebAuthorization - """ - - self._authorization = authorization - - @property - def expand_archive(self): - """ - Gets the expand_archive of this FileSourceCreateRequest. - Indicates whether compressed files should be expanded upon upload. - - :return: The expand_archive of this FileSourceCreateRequest. - :rtype: bool - """ - return self._expand_archive - - @expand_archive.setter - def expand_archive(self, expand_archive): - """ - Sets the expand_archive of this FileSourceCreateRequest. - Indicates whether compressed files should be expanded upon upload. - - :param expand_archive: The expand_archive of this FileSourceCreateRequest. - :type: bool - """ - - self._expand_archive = expand_archive - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, FileSourceCreateRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/file_source_summary_response.py b/datadotworld/client/_swagger/models/file_source_summary_response.py deleted file mode 100644 index 9d9c5b8..0000000 --- a/datadotworld/client/_swagger/models/file_source_summary_response.py +++ /dev/null @@ -1,426 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class FileSourceSummaryResponse(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'url': 'str', - 'method': 'str', - 'request_headers': 'dict(str, str)', - 'request_entity': 'str', - 'oauth_token': 'OauthTokenReference', - 'credentials': 'WebCredentials', - 'authorization': 'WebAuthorization', - 'sync_status': 'str', - 'sync_summary': 'str', - 'last_sync_start': 'str', - 'last_sync_success': 'str', - 'last_sync_failure': 'str' - } - - attribute_map = { - 'url': 'url', - 'method': 'method', - 'request_headers': 'requestHeaders', - 'request_entity': 'requestEntity', - 'oauth_token': 'oauthToken', - 'credentials': 'credentials', - 'authorization': 'authorization', - 'sync_status': 'syncStatus', - 'sync_summary': 'syncSummary', - 'last_sync_start': 'lastSyncStart', - 'last_sync_success': 'lastSyncSuccess', - 'last_sync_failure': 'lastSyncFailure' - } - - def __init__(self, url=None, method=None, request_headers=None, request_entity=None, oauth_token=None, credentials=None, authorization=None, sync_status=None, sync_summary=None, last_sync_start=None, last_sync_success=None, last_sync_failure=None): - """ - FileSourceSummaryResponse - a model defined in Swagger - """ - - self._url = None - self._method = None - self._request_headers = None - self._request_entity = None - self._oauth_token = None - self._credentials = None - self._authorization = None - self._sync_status = None - self._sync_summary = None - self._last_sync_start = None - self._last_sync_success = None - self._last_sync_failure = None - - self.url = url - self.method = method - if request_headers is not None: - self.request_headers = request_headers - if request_entity is not None: - self.request_entity = request_entity - if oauth_token is not None: - self.oauth_token = oauth_token - if credentials is not None: - self.credentials = credentials - if authorization is not None: - self.authorization = authorization - self.sync_status = sync_status - if sync_summary is not None: - self.sync_summary = sync_summary - if last_sync_start is not None: - self.last_sync_start = last_sync_start - if last_sync_success is not None: - self.last_sync_success = last_sync_success - if last_sync_failure is not None: - self.last_sync_failure = last_sync_failure - - @property - def url(self): - """ - Gets the url of this FileSourceSummaryResponse. - Source URL of file. Must be an http, https, or stream URL. - - :return: The url of this FileSourceSummaryResponse. - :rtype: str - """ - return self._url - - @url.setter - def url(self, url): - """ - Sets the url of this FileSourceSummaryResponse. - Source URL of file. Must be an http, https, or stream URL. - - :param url: The url of this FileSourceSummaryResponse. - :type: str - """ - if url is None: - raise ValueError("Invalid value for `url`, must not be `None`") - - self._url = url - - @property - def method(self): - """ - Gets the method of this FileSourceSummaryResponse. - - :return: The method of this FileSourceSummaryResponse. - :rtype: str - """ - return self._method - - @method.setter - def method(self, method): - """ - Sets the method of this FileSourceSummaryResponse. - - :param method: The method of this FileSourceSummaryResponse. - :type: str - """ - if method is None: - raise ValueError("Invalid value for `method`, must not be `None`") - - self._method = method - - @property - def request_headers(self): - """ - Gets the request_headers of this FileSourceSummaryResponse. - A map of custom HTTP header name/value pairs to pass with the request. If a `requestEntity` string is specified, this must contain a `Content-Type` header. - - :return: The request_headers of this FileSourceSummaryResponse. - :rtype: dict(str, str) - """ - return self._request_headers - - @request_headers.setter - def request_headers(self, request_headers): - """ - Sets the request_headers of this FileSourceSummaryResponse. - A map of custom HTTP header name/value pairs to pass with the request. If a `requestEntity` string is specified, this must contain a `Content-Type` header. - - :param request_headers: The request_headers of this FileSourceSummaryResponse. - :type: dict(str, str) - """ - - self._request_headers = request_headers - - @property - def request_entity(self): - """ - Gets the request_entity of this FileSourceSummaryResponse. - - :return: The request_entity of this FileSourceSummaryResponse. - :rtype: str - """ - return self._request_entity - - @request_entity.setter - def request_entity(self, request_entity): - """ - Sets the request_entity of this FileSourceSummaryResponse. - - :param request_entity: The request_entity of this FileSourceSummaryResponse. - :type: str - """ - - self._request_entity = request_entity - - @property - def oauth_token(self): - """ - Gets the oauth_token of this FileSourceSummaryResponse. - - :return: The oauth_token of this FileSourceSummaryResponse. - :rtype: OauthTokenReference - """ - return self._oauth_token - - @oauth_token.setter - def oauth_token(self, oauth_token): - """ - Sets the oauth_token of this FileSourceSummaryResponse. - - :param oauth_token: The oauth_token of this FileSourceSummaryResponse. - :type: OauthTokenReference - """ - - self._oauth_token = oauth_token - - @property - def credentials(self): - """ - Gets the credentials of this FileSourceSummaryResponse. - - :return: The credentials of this FileSourceSummaryResponse. - :rtype: WebCredentials - """ - return self._credentials - - @credentials.setter - def credentials(self, credentials): - """ - Sets the credentials of this FileSourceSummaryResponse. - - :param credentials: The credentials of this FileSourceSummaryResponse. - :type: WebCredentials - """ - - self._credentials = credentials - - @property - def authorization(self): - """ - Gets the authorization of this FileSourceSummaryResponse. - - :return: The authorization of this FileSourceSummaryResponse. - :rtype: WebAuthorization - """ - return self._authorization - - @authorization.setter - def authorization(self, authorization): - """ - Sets the authorization of this FileSourceSummaryResponse. - - :param authorization: The authorization of this FileSourceSummaryResponse. - :type: WebAuthorization - """ - - self._authorization = authorization - - @property - def sync_status(self): - """ - Gets the sync_status of this FileSourceSummaryResponse. - Synchronization status of the file. This status can be checked periodically after changes are made to the dataset to determine the status of asynchronous syncronization. * `NEW`: Just created. Not yet synchronized. * `INPROGRESS`: Currently being synchronized. * `LOADED`: Successfully synchronized. * `SYSTEMERROR`: Error state due to synchronization failure. - - :return: The sync_status of this FileSourceSummaryResponse. - :rtype: str - """ - return self._sync_status - - @sync_status.setter - def sync_status(self, sync_status): - """ - Sets the sync_status of this FileSourceSummaryResponse. - Synchronization status of the file. This status can be checked periodically after changes are made to the dataset to determine the status of asynchronous syncronization. * `NEW`: Just created. Not yet synchronized. * `INPROGRESS`: Currently being synchronized. * `LOADED`: Successfully synchronized. * `SYSTEMERROR`: Error state due to synchronization failure. - - :param sync_status: The sync_status of this FileSourceSummaryResponse. - :type: str - """ - if sync_status is None: - raise ValueError("Invalid value for `sync_status`, must not be `None`") - - self._sync_status = sync_status - - @property - def sync_summary(self): - """ - Gets the sync_summary of this FileSourceSummaryResponse. - Human-readable message detailing status of last failed sync. - - :return: The sync_summary of this FileSourceSummaryResponse. - :rtype: str - """ - return self._sync_summary - - @sync_summary.setter - def sync_summary(self, sync_summary): - """ - Sets the sync_summary of this FileSourceSummaryResponse. - Human-readable message detailing status of last failed sync. - - :param sync_summary: The sync_summary of this FileSourceSummaryResponse. - :type: str - """ - - self._sync_summary = sync_summary - - @property - def last_sync_start(self): - """ - Gets the last_sync_start of this FileSourceSummaryResponse. - Date and time when synchronization last started. - - :return: The last_sync_start of this FileSourceSummaryResponse. - :rtype: str - """ - return self._last_sync_start - - @last_sync_start.setter - def last_sync_start(self, last_sync_start): - """ - Sets the last_sync_start of this FileSourceSummaryResponse. - Date and time when synchronization last started. - - :param last_sync_start: The last_sync_start of this FileSourceSummaryResponse. - :type: str - """ - - self._last_sync_start = last_sync_start - - @property - def last_sync_success(self): - """ - Gets the last_sync_success of this FileSourceSummaryResponse. - Date and time when synchronization last finished successfully. - - :return: The last_sync_success of this FileSourceSummaryResponse. - :rtype: str - """ - return self._last_sync_success - - @last_sync_success.setter - def last_sync_success(self, last_sync_success): - """ - Sets the last_sync_success of this FileSourceSummaryResponse. - Date and time when synchronization last finished successfully. - - :param last_sync_success: The last_sync_success of this FileSourceSummaryResponse. - :type: str - """ - - self._last_sync_success = last_sync_success - - @property - def last_sync_failure(self): - """ - Gets the last_sync_failure of this FileSourceSummaryResponse. - Date and time when synchronization last failed. - - :return: The last_sync_failure of this FileSourceSummaryResponse. - :rtype: str - """ - return self._last_sync_failure - - @last_sync_failure.setter - def last_sync_failure(self, last_sync_failure): - """ - Sets the last_sync_failure of this FileSourceSummaryResponse. - Date and time when synchronization last failed. - - :param last_sync_failure: The last_sync_failure of this FileSourceSummaryResponse. - :type: str - """ - - self._last_sync_failure = last_sync_failure - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, FileSourceSummaryResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/file_summary_response.py b/datadotworld/client/_swagger/models/file_summary_response.py deleted file mode 100644 index 754f71b..0000000 --- a/datadotworld/client/_swagger/models/file_summary_response.py +++ /dev/null @@ -1,292 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class FileSummaryResponse(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'name': 'str', - 'source': 'FileSourceSummaryResponse', - 'description': 'str', - 'labels': 'list[str]', - 'size_in_bytes': 'int', - 'created': 'str', - 'updated': 'str' - } - - attribute_map = { - 'name': 'name', - 'source': 'source', - 'description': 'description', - 'labels': 'labels', - 'size_in_bytes': 'sizeInBytes', - 'created': 'created', - 'updated': 'updated' - } - - def __init__(self, name=None, source=None, description=None, labels=None, size_in_bytes=None, created=None, updated=None): - """ - FileSummaryResponse - a model defined in Swagger - """ - - self._name = None - self._source = None - self._description = None - self._labels = None - self._size_in_bytes = None - self._created = None - self._updated = None - - self.name = name - if source is not None: - self.source = source - if description is not None: - self.description = description - if labels is not None: - self.labels = labels - if size_in_bytes is not None: - self.size_in_bytes = size_in_bytes - self.created = created - self.updated = updated - - @property - def name(self): - """ - Gets the name of this FileSummaryResponse. - File name. Should include type extension always when possible. Must not include slashes. - - :return: The name of this FileSummaryResponse. - :rtype: str - """ - return self._name - - @name.setter - def name(self, name): - """ - Sets the name of this FileSummaryResponse. - File name. Should include type extension always when possible. Must not include slashes. - - :param name: The name of this FileSummaryResponse. - :type: str - """ - if name is None: - raise ValueError("Invalid value for `name`, must not be `None`") - - self._name = name - - @property - def source(self): - """ - Gets the source of this FileSummaryResponse. - - :return: The source of this FileSummaryResponse. - :rtype: FileSourceSummaryResponse - """ - return self._source - - @source.setter - def source(self, source): - """ - Sets the source of this FileSummaryResponse. - - :param source: The source of this FileSummaryResponse. - :type: FileSourceSummaryResponse - """ - - self._source = source - - @property - def description(self): - """ - Gets the description of this FileSummaryResponse. - File description. - - :return: The description of this FileSummaryResponse. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this FileSummaryResponse. - File description. - - :param description: The description of this FileSummaryResponse. - :type: str - """ - - self._description = description - - @property - def labels(self): - """ - Gets the labels of this FileSummaryResponse. - File labels. - - :return: The labels of this FileSummaryResponse. - :rtype: list[str] - """ - return self._labels - - @labels.setter - def labels(self, labels): - """ - Sets the labels of this FileSummaryResponse. - File labels. - - :param labels: The labels of this FileSummaryResponse. - :type: list[str] - """ - - self._labels = labels - - @property - def size_in_bytes(self): - """ - Gets the size_in_bytes of this FileSummaryResponse. - - :return: The size_in_bytes of this FileSummaryResponse. - :rtype: int - """ - return self._size_in_bytes - - @size_in_bytes.setter - def size_in_bytes(self, size_in_bytes): - """ - Sets the size_in_bytes of this FileSummaryResponse. - - :param size_in_bytes: The size_in_bytes of this FileSummaryResponse. - :type: int - """ - - self._size_in_bytes = size_in_bytes - - @property - def created(self): - """ - Gets the created of this FileSummaryResponse. - Date and time when file was created. - - :return: The created of this FileSummaryResponse. - :rtype: str - """ - return self._created - - @created.setter - def created(self, created): - """ - Sets the created of this FileSummaryResponse. - Date and time when file was created. - - :param created: The created of this FileSummaryResponse. - :type: str - """ - if created is None: - raise ValueError("Invalid value for `created`, must not be `None`") - - self._created = created - - @property - def updated(self): - """ - Gets the updated of this FileSummaryResponse. - Date and time when file was last updated. - - :return: The updated of this FileSummaryResponse. - :rtype: str - """ - return self._updated - - @updated.setter - def updated(self, updated): - """ - Sets the updated of this FileSummaryResponse. - Date and time when file was last updated. - - :param updated: The updated of this FileSummaryResponse. - :type: str - """ - if updated is None: - raise ValueError("Invalid value for `updated`, must not be `None`") - - self._updated = updated - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, FileSummaryResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/insight_body.py b/datadotworld/client/_swagger/models/insight_body.py deleted file mode 100644 index 8d738e9..0000000 --- a/datadotworld/client/_swagger/models/insight_body.py +++ /dev/null @@ -1,181 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class InsightBody(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'image_url': 'str', - 'embed_url': 'str', - 'markdown_body': 'str' - } - - attribute_map = { - 'image_url': 'imageUrl', - 'embed_url': 'embedUrl', - 'markdown_body': 'markdownBody' - } - - def __init__(self, image_url=None, embed_url=None, markdown_body=None): - """ - InsightBody - a model defined in Swagger - """ - - self._image_url = None - self._embed_url = None - self._markdown_body = None - - if image_url is not None: - self.image_url = image_url - if embed_url is not None: - self.embed_url = embed_url - if markdown_body is not None: - self.markdown_body = markdown_body - - @property - def image_url(self): - """ - Gets the image_url of this InsightBody. - Image URL - - :return: The image_url of this InsightBody. - :rtype: str - """ - return self._image_url - - @image_url.setter - def image_url(self, image_url): - """ - Sets the image_url of this InsightBody. - Image URL - - :param image_url: The image_url of this InsightBody. - :type: str - """ - - self._image_url = image_url - - @property - def embed_url(self): - """ - Gets the embed_url of this InsightBody. - oEmbed URL. - - :return: The embed_url of this InsightBody. - :rtype: str - """ - return self._embed_url - - @embed_url.setter - def embed_url(self, embed_url): - """ - Sets the embed_url of this InsightBody. - oEmbed URL. - - :param embed_url: The embed_url of this InsightBody. - :type: str - """ - - self._embed_url = embed_url - - @property - def markdown_body(self): - """ - Gets the markdown_body of this InsightBody. - Markdown (deprecated) - - :return: The markdown_body of this InsightBody. - :rtype: str - """ - return self._markdown_body - - @markdown_body.setter - def markdown_body(self, markdown_body): - """ - Sets the markdown_body of this InsightBody. - Markdown (deprecated) - - :param markdown_body: The markdown_body of this InsightBody. - :type: str - """ - - self._markdown_body = markdown_body - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, InsightBody): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/insight_create_request.py b/datadotworld/client/_swagger/models/insight_create_request.py deleted file mode 100644 index c7c1fb1..0000000 --- a/datadotworld/client/_swagger/models/insight_create_request.py +++ /dev/null @@ -1,243 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class InsightCreateRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'title': 'str', - 'description': 'str', - 'body': 'InsightBody', - 'source_link': 'str', - 'data_source_links': 'list[str]' - } - - attribute_map = { - 'title': 'title', - 'description': 'description', - 'body': 'body', - 'source_link': 'sourceLink', - 'data_source_links': 'dataSourceLinks' - } - - def __init__(self, title=None, description=None, body=None, source_link=None, data_source_links=None): - """ - InsightCreateRequest - a model defined in Swagger - """ - - self._title = None - self._description = None - self._body = None - self._source_link = None - self._data_source_links = None - - self.title = title - if description is not None: - self.description = description - self.body = body - if source_link is not None: - self.source_link = source_link - if data_source_links is not None: - self.data_source_links = data_source_links - - @property - def title(self): - """ - Gets the title of this InsightCreateRequest. - Insight title. - - :return: The title of this InsightCreateRequest. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this InsightCreateRequest. - Insight title. - - :param title: The title of this InsightCreateRequest. - :type: str - """ - if title is None: - raise ValueError("Invalid value for `title`, must not be `None`") - if title is not None and len(title) > 128: - raise ValueError("Invalid value for `title`, length must be less than or equal to `128`") - if title is not None and len(title) < 1: - raise ValueError("Invalid value for `title`, length must be greater than or equal to `1`") - - self._title = title - - @property - def description(self): - """ - Gets the description of this InsightCreateRequest. - Insight description. - - :return: The description of this InsightCreateRequest. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this InsightCreateRequest. - Insight description. - - :param description: The description of this InsightCreateRequest. - :type: str - """ - if description is not None and len(description) > 150: - raise ValueError("Invalid value for `description`, length must be less than or equal to `150`") - - self._description = description - - @property - def body(self): - """ - Gets the body of this InsightCreateRequest. - - :return: The body of this InsightCreateRequest. - :rtype: InsightBody - """ - return self._body - - @body.setter - def body(self, body): - """ - Sets the body of this InsightCreateRequest. - - :param body: The body of this InsightCreateRequest. - :type: InsightBody - """ - if body is None: - raise ValueError("Invalid value for `body`, must not be `None`") - - self._body = body - - @property - def source_link(self): - """ - Gets the source_link of this InsightCreateRequest. - Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight. - - :return: The source_link of this InsightCreateRequest. - :rtype: str - """ - return self._source_link - - @source_link.setter - def source_link(self, source_link): - """ - Sets the source_link of this InsightCreateRequest. - Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight. - - :param source_link: The source_link of this InsightCreateRequest. - :type: str - """ - - self._source_link = source_link - - @property - def data_source_links(self): - """ - Gets the data_source_links of this InsightCreateRequest. - One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight. - - :return: The data_source_links of this InsightCreateRequest. - :rtype: list[str] - """ - return self._data_source_links - - @data_source_links.setter - def data_source_links(self, data_source_links): - """ - Sets the data_source_links of this InsightCreateRequest. - One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight. - - :param data_source_links: The data_source_links of this InsightCreateRequest. - :type: list[str] - """ - - self._data_source_links = data_source_links - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, InsightCreateRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/insight_patch_request.py b/datadotworld/client/_swagger/models/insight_patch_request.py deleted file mode 100644 index 06299b6..0000000 --- a/datadotworld/client/_swagger/models/insight_patch_request.py +++ /dev/null @@ -1,241 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class InsightPatchRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'title': 'str', - 'description': 'str', - 'body': 'InsightBody', - 'source_link': 'str', - 'data_source_links': 'list[str]' - } - - attribute_map = { - 'title': 'title', - 'description': 'description', - 'body': 'body', - 'source_link': 'sourceLink', - 'data_source_links': 'dataSourceLinks' - } - - def __init__(self, title=None, description=None, body=None, source_link=None, data_source_links=None): - """ - InsightPatchRequest - a model defined in Swagger - """ - - self._title = None - self._description = None - self._body = None - self._source_link = None - self._data_source_links = None - - if title is not None: - self.title = title - if description is not None: - self.description = description - if body is not None: - self.body = body - if source_link is not None: - self.source_link = source_link - if data_source_links is not None: - self.data_source_links = data_source_links - - @property - def title(self): - """ - Gets the title of this InsightPatchRequest. - Insight title. - - :return: The title of this InsightPatchRequest. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this InsightPatchRequest. - Insight title. - - :param title: The title of this InsightPatchRequest. - :type: str - """ - if title is not None and len(title) > 128: - raise ValueError("Invalid value for `title`, length must be less than or equal to `128`") - if title is not None and len(title) < 1: - raise ValueError("Invalid value for `title`, length must be greater than or equal to `1`") - - self._title = title - - @property - def description(self): - """ - Gets the description of this InsightPatchRequest. - Insight description. - - :return: The description of this InsightPatchRequest. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this InsightPatchRequest. - Insight description. - - :param description: The description of this InsightPatchRequest. - :type: str - """ - if description is not None and len(description) > 150: - raise ValueError("Invalid value for `description`, length must be less than or equal to `150`") - - self._description = description - - @property - def body(self): - """ - Gets the body of this InsightPatchRequest. - - :return: The body of this InsightPatchRequest. - :rtype: InsightBody - """ - return self._body - - @body.setter - def body(self, body): - """ - Sets the body of this InsightPatchRequest. - - :param body: The body of this InsightPatchRequest. - :type: InsightBody - """ - - self._body = body - - @property - def source_link(self): - """ - Gets the source_link of this InsightPatchRequest. - Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight. - - :return: The source_link of this InsightPatchRequest. - :rtype: str - """ - return self._source_link - - @source_link.setter - def source_link(self, source_link): - """ - Sets the source_link of this InsightPatchRequest. - Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight. - - :param source_link: The source_link of this InsightPatchRequest. - :type: str - """ - - self._source_link = source_link - - @property - def data_source_links(self): - """ - Gets the data_source_links of this InsightPatchRequest. - One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight. - - :return: The data_source_links of this InsightPatchRequest. - :rtype: list[str] - """ - return self._data_source_links - - @data_source_links.setter - def data_source_links(self, data_source_links): - """ - Sets the data_source_links of this InsightPatchRequest. - One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight. - - :param data_source_links: The data_source_links of this InsightPatchRequest. - :type: list[str] - """ - - self._data_source_links = data_source_links - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, InsightPatchRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/insight_put_request.py b/datadotworld/client/_swagger/models/insight_put_request.py deleted file mode 100644 index 8f2c241..0000000 --- a/datadotworld/client/_swagger/models/insight_put_request.py +++ /dev/null @@ -1,243 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class InsightPutRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'title': 'str', - 'description': 'str', - 'body': 'InsightBody', - 'source_link': 'str', - 'data_source_links': 'list[str]' - } - - attribute_map = { - 'title': 'title', - 'description': 'description', - 'body': 'body', - 'source_link': 'sourceLink', - 'data_source_links': 'dataSourceLinks' - } - - def __init__(self, title=None, description=None, body=None, source_link=None, data_source_links=None): - """ - InsightPutRequest - a model defined in Swagger - """ - - self._title = None - self._description = None - self._body = None - self._source_link = None - self._data_source_links = None - - self.title = title - if description is not None: - self.description = description - self.body = body - if source_link is not None: - self.source_link = source_link - if data_source_links is not None: - self.data_source_links = data_source_links - - @property - def title(self): - """ - Gets the title of this InsightPutRequest. - Insight title. - - :return: The title of this InsightPutRequest. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this InsightPutRequest. - Insight title. - - :param title: The title of this InsightPutRequest. - :type: str - """ - if title is None: - raise ValueError("Invalid value for `title`, must not be `None`") - if title is not None and len(title) > 128: - raise ValueError("Invalid value for `title`, length must be less than or equal to `128`") - if title is not None and len(title) < 1: - raise ValueError("Invalid value for `title`, length must be greater than or equal to `1`") - - self._title = title - - @property - def description(self): - """ - Gets the description of this InsightPutRequest. - Insight description. - - :return: The description of this InsightPutRequest. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this InsightPutRequest. - Insight description. - - :param description: The description of this InsightPutRequest. - :type: str - """ - if description is not None and len(description) > 150: - raise ValueError("Invalid value for `description`, length must be less than or equal to `150`") - - self._description = description - - @property - def body(self): - """ - Gets the body of this InsightPutRequest. - - :return: The body of this InsightPutRequest. - :rtype: InsightBody - """ - return self._body - - @body.setter - def body(self, body): - """ - Sets the body of this InsightPutRequest. - - :param body: The body of this InsightPutRequest. - :type: InsightBody - """ - if body is None: - raise ValueError("Invalid value for `body`, must not be `None`") - - self._body = body - - @property - def source_link(self): - """ - Gets the source_link of this InsightPutRequest. - Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight. - - :return: The source_link of this InsightPutRequest. - :rtype: str - """ - return self._source_link - - @source_link.setter - def source_link(self, source_link): - """ - Sets the source_link of this InsightPutRequest. - Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight. - - :param source_link: The source_link of this InsightPutRequest. - :type: str - """ - - self._source_link = source_link - - @property - def data_source_links(self): - """ - Gets the data_source_links of this InsightPutRequest. - One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight. - - :return: The data_source_links of this InsightPutRequest. - :rtype: list[str] - """ - return self._data_source_links - - @data_source_links.setter - def data_source_links(self, data_source_links): - """ - Sets the data_source_links of this InsightPutRequest. - One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight. - - :param data_source_links: The data_source_links of this InsightPutRequest. - :type: list[str] - """ - - self._data_source_links = data_source_links - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, InsightPutRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/insight_summary_response.py b/datadotworld/client/_swagger/models/insight_summary_response.py deleted file mode 100644 index 3d80c5f..0000000 --- a/datadotworld/client/_swagger/models/insight_summary_response.py +++ /dev/null @@ -1,353 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class InsightSummaryResponse(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'id': 'str', - 'title': 'str', - 'description': 'str', - 'body': 'InsightBody', - 'source_link': 'str', - 'data_source_links': 'list[str]', - 'author': 'str', - 'created': 'str', - 'updated': 'str' - } - - attribute_map = { - 'id': 'id', - 'title': 'title', - 'description': 'description', - 'body': 'body', - 'source_link': 'sourceLink', - 'data_source_links': 'dataSourceLinks', - 'author': 'author', - 'created': 'created', - 'updated': 'updated' - } - - def __init__(self, id=None, title=None, description=None, body=None, source_link=None, data_source_links=None, author=None, created=None, updated=None): - """ - InsightSummaryResponse - a model defined in Swagger - """ - - self._id = None - self._title = None - self._description = None - self._body = None - self._source_link = None - self._data_source_links = None - self._author = None - self._created = None - self._updated = None - - self.id = id - self.title = title - if description is not None: - self.description = description - self.body = body - if source_link is not None: - self.source_link = source_link - if data_source_links is not None: - self.data_source_links = data_source_links - self.author = author - self.created = created - self.updated = updated - - @property - def id(self): - """ - Gets the id of this InsightSummaryResponse. - Unique Insight id. - - :return: The id of this InsightSummaryResponse. - :rtype: str - """ - return self._id - - @id.setter - def id(self, id): - """ - Sets the id of this InsightSummaryResponse. - Unique Insight id. - - :param id: The id of this InsightSummaryResponse. - :type: str - """ - if id is None: - raise ValueError("Invalid value for `id`, must not be `None`") - - self._id = id - - @property - def title(self): - """ - Gets the title of this InsightSummaryResponse. - Insight title. - - :return: The title of this InsightSummaryResponse. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this InsightSummaryResponse. - Insight title. - - :param title: The title of this InsightSummaryResponse. - :type: str - """ - if title is None: - raise ValueError("Invalid value for `title`, must not be `None`") - - self._title = title - - @property - def description(self): - """ - Gets the description of this InsightSummaryResponse. - Insight description. - - :return: The description of this InsightSummaryResponse. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this InsightSummaryResponse. - Insight description. - - :param description: The description of this InsightSummaryResponse. - :type: str - """ - - self._description = description - - @property - def body(self): - """ - Gets the body of this InsightSummaryResponse. - - :return: The body of this InsightSummaryResponse. - :rtype: InsightBody - """ - return self._body - - @body.setter - def body(self, body): - """ - Sets the body of this InsightSummaryResponse. - - :param body: The body of this InsightSummaryResponse. - :type: InsightBody - """ - if body is None: - raise ValueError("Invalid value for `body`, must not be `None`") - - self._body = body - - @property - def source_link(self): - """ - Gets the source_link of this InsightSummaryResponse. - Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight. - - :return: The source_link of this InsightSummaryResponse. - :rtype: str - """ - return self._source_link - - @source_link.setter - def source_link(self, source_link): - """ - Sets the source_link of this InsightSummaryResponse. - Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight. - - :param source_link: The source_link of this InsightSummaryResponse. - :type: str - """ - - self._source_link = source_link - - @property - def data_source_links(self): - """ - Gets the data_source_links of this InsightSummaryResponse. - One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight. - - :return: The data_source_links of this InsightSummaryResponse. - :rtype: list[str] - """ - return self._data_source_links - - @data_source_links.setter - def data_source_links(self, data_source_links): - """ - Sets the data_source_links of this InsightSummaryResponse. - One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight. - - :param data_source_links: The data_source_links of this InsightSummaryResponse. - :type: list[str] - """ - - self._data_source_links = data_source_links - - @property - def author(self): - """ - Gets the author of this InsightSummaryResponse. - User name of the author of the insight. - - :return: The author of this InsightSummaryResponse. - :rtype: str - """ - return self._author - - @author.setter - def author(self, author): - """ - Sets the author of this InsightSummaryResponse. - User name of the author of the insight. - - :param author: The author of this InsightSummaryResponse. - :type: str - """ - if author is None: - raise ValueError("Invalid value for `author`, must not be `None`") - - self._author = author - - @property - def created(self): - """ - Gets the created of this InsightSummaryResponse. - Date and time when insight was created. - - :return: The created of this InsightSummaryResponse. - :rtype: str - """ - return self._created - - @created.setter - def created(self, created): - """ - Sets the created of this InsightSummaryResponse. - Date and time when insight was created. - - :param created: The created of this InsightSummaryResponse. - :type: str - """ - if created is None: - raise ValueError("Invalid value for `created`, must not be `None`") - - self._created = created - - @property - def updated(self): - """ - Gets the updated of this InsightSummaryResponse. - Date and time when insight was last updated. - - :return: The updated of this InsightSummaryResponse. - :rtype: str - """ - return self._updated - - @updated.setter - def updated(self, updated): - """ - Sets the updated of this InsightSummaryResponse. - Date and time when insight was last updated. - - :param updated: The updated of this InsightSummaryResponse. - :type: str - """ - if updated is None: - raise ValueError("Invalid value for `updated`, must not be `None`") - - self._updated = updated - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, InsightSummaryResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/linked_dataset_create_or_update_request.py b/datadotworld/client/_swagger/models/linked_dataset_create_or_update_request.py deleted file mode 100644 index 4233721..0000000 --- a/datadotworld/client/_swagger/models/linked_dataset_create_or_update_request.py +++ /dev/null @@ -1,159 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class LinkedDatasetCreateOrUpdateRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'owner': 'str', - 'id': 'str' - } - - attribute_map = { - 'owner': 'owner', - 'id': 'id' - } - - def __init__(self, owner=None, id=None): - """ - LinkedDatasetCreateOrUpdateRequest - a model defined in Swagger - """ - - self._owner = None - self._id = None - - self.owner = owner - self.id = id - - @property - def owner(self): - """ - Gets the owner of this LinkedDatasetCreateOrUpdateRequest. - User name and unique identifier of the creator of the dataset. - - :return: The owner of this LinkedDatasetCreateOrUpdateRequest. - :rtype: str - """ - return self._owner - - @owner.setter - def owner(self, owner): - """ - Sets the owner of this LinkedDatasetCreateOrUpdateRequest. - User name and unique identifier of the creator of the dataset. - - :param owner: The owner of this LinkedDatasetCreateOrUpdateRequest. - :type: str - """ - if owner is None: - raise ValueError("Invalid value for `owner`, must not be `None`") - if owner is not None and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', owner): - raise ValueError("Invalid value for `owner`, must be a follow pattern or equal to `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - self._owner = owner - - @property - def id(self): - """ - Gets the id of this LinkedDatasetCreateOrUpdateRequest. - Unique identifier of dataset. - - :return: The id of this LinkedDatasetCreateOrUpdateRequest. - :rtype: str - """ - return self._id - - @id.setter - def id(self, id): - """ - Sets the id of this LinkedDatasetCreateOrUpdateRequest. - Unique identifier of dataset. - - :param id: The id of this LinkedDatasetCreateOrUpdateRequest. - :type: str - """ - if id is None: - raise ValueError("Invalid value for `id`, must not be `None`") - if id is not None and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', id): - raise ValueError("Invalid value for `id`, must be a follow pattern or equal to `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - self._id = id - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, LinkedDatasetCreateOrUpdateRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/linked_dataset_summary_response.py b/datadotworld/client/_swagger/models/linked_dataset_summary_response.py deleted file mode 100644 index 4321c0f..0000000 --- a/datadotworld/client/_swagger/models/linked_dataset_summary_response.py +++ /dev/null @@ -1,412 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class LinkedDatasetSummaryResponse(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'owner': 'str', - 'id': 'str', - 'title': 'str', - 'description': 'str', - 'summary': 'str', - 'tags': 'list[str]', - 'license': 'str', - 'visibility': 'str', - 'created': 'str', - 'updated': 'str', - 'access_level': 'str' - } - - attribute_map = { - 'owner': 'owner', - 'id': 'id', - 'title': 'title', - 'description': 'description', - 'summary': 'summary', - 'tags': 'tags', - 'license': 'license', - 'visibility': 'visibility', - 'created': 'created', - 'updated': 'updated', - 'access_level': 'accessLevel' - } - - def __init__(self, owner=None, id=None, title=None, description=None, summary=None, tags=None, license=None, visibility=None, created=None, updated=None, access_level=None): - """ - LinkedDatasetSummaryResponse - a model defined in Swagger - """ - - self._owner = None - self._id = None - self._title = None - self._description = None - self._summary = None - self._tags = None - self._license = None - self._visibility = None - self._created = None - self._updated = None - self._access_level = None - - self.owner = owner - self.id = id - self.title = title - if description is not None: - self.description = description - if summary is not None: - self.summary = summary - if tags is not None: - self.tags = tags - if license is not None: - self.license = license - self.visibility = visibility - self.created = created - self.updated = updated - self.access_level = access_level - - @property - def owner(self): - """ - Gets the owner of this LinkedDatasetSummaryResponse. - User name and unique identifier of the creator of the dataset. - - :return: The owner of this LinkedDatasetSummaryResponse. - :rtype: str - """ - return self._owner - - @owner.setter - def owner(self, owner): - """ - Sets the owner of this LinkedDatasetSummaryResponse. - User name and unique identifier of the creator of the dataset. - - :param owner: The owner of this LinkedDatasetSummaryResponse. - :type: str - """ - if owner is None: - raise ValueError("Invalid value for `owner`, must not be `None`") - - self._owner = owner - - @property - def id(self): - """ - Gets the id of this LinkedDatasetSummaryResponse. - Unique identifier of dataset. - - :return: The id of this LinkedDatasetSummaryResponse. - :rtype: str - """ - return self._id - - @id.setter - def id(self, id): - """ - Sets the id of this LinkedDatasetSummaryResponse. - Unique identifier of dataset. - - :param id: The id of this LinkedDatasetSummaryResponse. - :type: str - """ - if id is None: - raise ValueError("Invalid value for `id`, must not be `None`") - - self._id = id - - @property - def title(self): - """ - Gets the title of this LinkedDatasetSummaryResponse. - Dataset name. - - :return: The title of this LinkedDatasetSummaryResponse. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this LinkedDatasetSummaryResponse. - Dataset name. - - :param title: The title of this LinkedDatasetSummaryResponse. - :type: str - """ - if title is None: - raise ValueError("Invalid value for `title`, must not be `None`") - - self._title = title - - @property - def description(self): - """ - Gets the description of this LinkedDatasetSummaryResponse. - Short dataset description. - - :return: The description of this LinkedDatasetSummaryResponse. - :rtype: str - """ - return self._description - - @description.setter - def description(self, description): - """ - Sets the description of this LinkedDatasetSummaryResponse. - Short dataset description. - - :param description: The description of this LinkedDatasetSummaryResponse. - :type: str - """ - - self._description = description - - @property - def summary(self): - """ - Gets the summary of this LinkedDatasetSummaryResponse. - Long-form dataset summary (Markdown supported). - - :return: The summary of this LinkedDatasetSummaryResponse. - :rtype: str - """ - return self._summary - - @summary.setter - def summary(self, summary): - """ - Sets the summary of this LinkedDatasetSummaryResponse. - Long-form dataset summary (Markdown supported). - - :param summary: The summary of this LinkedDatasetSummaryResponse. - :type: str - """ - - self._summary = summary - - @property - def tags(self): - """ - Gets the tags of this LinkedDatasetSummaryResponse. - Dataset tags. Letters numbers and spaces only (max 25 characters). - - :return: The tags of this LinkedDatasetSummaryResponse. - :rtype: list[str] - """ - return self._tags - - @tags.setter - def tags(self, tags): - """ - Sets the tags of this LinkedDatasetSummaryResponse. - Dataset tags. Letters numbers and spaces only (max 25 characters). - - :param tags: The tags of this LinkedDatasetSummaryResponse. - :type: list[str] - """ - - self._tags = tags - - @property - def license(self): - """ - Gets the license of this LinkedDatasetSummaryResponse. - Dataset license. Find additional info for allowed values [here](https://data.world/license-help). - - :return: The license of this LinkedDatasetSummaryResponse. - :rtype: str - """ - return self._license - - @license.setter - def license(self, license): - """ - Sets the license of this LinkedDatasetSummaryResponse. - Dataset license. Find additional info for allowed values [here](https://data.world/license-help). - - :param license: The license of this LinkedDatasetSummaryResponse. - :type: str - """ - - self._license = license - - @property - def visibility(self): - """ - Gets the visibility of this LinkedDatasetSummaryResponse. - Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. - - :return: The visibility of this LinkedDatasetSummaryResponse. - :rtype: str - """ - return self._visibility - - @visibility.setter - def visibility(self, visibility): - """ - Sets the visibility of this LinkedDatasetSummaryResponse. - Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. - - :param visibility: The visibility of this LinkedDatasetSummaryResponse. - :type: str - """ - if visibility is None: - raise ValueError("Invalid value for `visibility`, must not be `None`") - - self._visibility = visibility - - @property - def created(self): - """ - Gets the created of this LinkedDatasetSummaryResponse. - Date and time when the dataset was created. - - :return: The created of this LinkedDatasetSummaryResponse. - :rtype: str - """ - return self._created - - @created.setter - def created(self, created): - """ - Sets the created of this LinkedDatasetSummaryResponse. - Date and time when the dataset was created. - - :param created: The created of this LinkedDatasetSummaryResponse. - :type: str - """ - if created is None: - raise ValueError("Invalid value for `created`, must not be `None`") - - self._created = created - - @property - def updated(self): - """ - Gets the updated of this LinkedDatasetSummaryResponse. - Date and time when the dataset was last updated. - - :return: The updated of this LinkedDatasetSummaryResponse. - :rtype: str - """ - return self._updated - - @updated.setter - def updated(self, updated): - """ - Sets the updated of this LinkedDatasetSummaryResponse. - Date and time when the dataset was last updated. - - :param updated: The updated of this LinkedDatasetSummaryResponse. - :type: str - """ - if updated is None: - raise ValueError("Invalid value for `updated`, must not be `None`") - - self._updated = updated - - @property - def access_level(self): - """ - Gets the access_level of this LinkedDatasetSummaryResponse. - The level of access the authenticated user is allowed with respect to dataset: * `NONE` Not allowed any access. * `READ` Allowed to know that the dataset exists, view and download data and metadata. * `WRITE` Allowed to update data and metadata, in addition to what READ allows. * `ADMIN` Allowed to delete dataset, in addition to what WRITE allows. - - :return: The access_level of this LinkedDatasetSummaryResponse. - :rtype: str - """ - return self._access_level - - @access_level.setter - def access_level(self, access_level): - """ - Sets the access_level of this LinkedDatasetSummaryResponse. - The level of access the authenticated user is allowed with respect to dataset: * `NONE` Not allowed any access. * `READ` Allowed to know that the dataset exists, view and download data and metadata. * `WRITE` Allowed to update data and metadata, in addition to what READ allows. * `ADMIN` Allowed to delete dataset, in addition to what WRITE allows. - - :param access_level: The access_level of this LinkedDatasetSummaryResponse. - :type: str - """ - if access_level is None: - raise ValueError("Invalid value for `access_level`, must not be `None`") - - self._access_level = access_level - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, LinkedDatasetSummaryResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/oauth_token_reference.py b/datadotworld/client/_swagger/models/oauth_token_reference.py deleted file mode 100644 index 6d80524..0000000 --- a/datadotworld/client/_swagger/models/oauth_token_reference.py +++ /dev/null @@ -1,192 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class OauthTokenReference(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'owner': 'str', - 'site': 'str', - 'id': 'str' - } - - attribute_map = { - 'owner': 'owner', - 'site': 'site', - 'id': 'id' - } - - def __init__(self, owner=None, site=None, id=None): - """ - OauthTokenReference - a model defined in Swagger - """ - - self._owner = None - self._site = None - self._id = None - - self.owner = owner - self.site = site - self.id = id - - @property - def owner(self): - """ - Gets the owner of this OauthTokenReference. - User name of the owner of the OAuth token within data.world. - - :return: The owner of this OauthTokenReference. - :rtype: str - """ - return self._owner - - @owner.setter - def owner(self, owner): - """ - Sets the owner of this OauthTokenReference. - User name of the owner of the OAuth token within data.world. - - :param owner: The owner of this OauthTokenReference. - :type: str - """ - if owner is None: - raise ValueError("Invalid value for `owner`, must not be `None`") - if owner is not None and len(owner) > 31: - raise ValueError("Invalid value for `owner`, length must be less than or equal to `31`") - if owner is not None and len(owner) < 3: - raise ValueError("Invalid value for `owner`, length must be greater than or equal to `3`") - if owner is not None and not re.search('[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]', owner): - raise ValueError("Invalid value for `owner`, must be a follow pattern or equal to `/[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]/`") - - self._owner = owner - - @property - def site(self): - """ - Gets the site of this OauthTokenReference. - - :return: The site of this OauthTokenReference. - :rtype: str - """ - return self._site - - @site.setter - def site(self, site): - """ - Sets the site of this OauthTokenReference. - - :param site: The site of this OauthTokenReference. - :type: str - """ - if site is None: - raise ValueError("Invalid value for `site`, must not be `None`") - if site is not None and len(site) > 255: - raise ValueError("Invalid value for `site`, length must be less than or equal to `255`") - if site is not None and len(site) < 3: - raise ValueError("Invalid value for `site`, length must be greater than or equal to `3`") - if site is not None and not re.search('(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?\\.)+[a-z]{2,}(?:@[a-z0-9](?:[-.](?=[a-z0-9])|[a-z0-9]){0,29})?', site): - raise ValueError("Invalid value for `site`, must be a follow pattern or equal to `/(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?\\.)+[a-z]{2,}(?:@[a-z0-9](?:[-.](?=[a-z0-9])|[a-z0-9]){0,29})?/`") - - self._site = site - - @property - def id(self): - """ - Gets the id of this OauthTokenReference. - - :return: The id of this OauthTokenReference. - :rtype: str - """ - return self._id - - @id.setter - def id(self, id): - """ - Sets the id of this OauthTokenReference. - - :param id: The id of this OauthTokenReference. - :type: str - """ - if id is None: - raise ValueError("Invalid value for `id`, must not be `None`") - - self._id = id - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, OauthTokenReference): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/paginated_dataset_results.py b/datadotworld/client/_swagger/models/paginated_dataset_results.py deleted file mode 100644 index 068ba28..0000000 --- a/datadotworld/client/_swagger/models/paginated_dataset_results.py +++ /dev/null @@ -1,179 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class PaginatedDatasetResults(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'count': 'int', - 'records': 'list[DatasetSummaryResponse]', - 'next_page_token': 'str' - } - - attribute_map = { - 'count': 'count', - 'records': 'records', - 'next_page_token': 'nextPageToken' - } - - def __init__(self, count=None, records=None, next_page_token=None): - """ - PaginatedDatasetResults - a model defined in Swagger - """ - - self._count = None - self._records = None - self._next_page_token = None - - self.count = count - self.records = records - if next_page_token is not None: - self.next_page_token = next_page_token - - @property - def count(self): - """ - Gets the count of this PaginatedDatasetResults. - - :return: The count of this PaginatedDatasetResults. - :rtype: int - """ - return self._count - - @count.setter - def count(self, count): - """ - Sets the count of this PaginatedDatasetResults. - - :param count: The count of this PaginatedDatasetResults. - :type: int - """ - if count is None: - raise ValueError("Invalid value for `count`, must not be `None`") - if count is not None and count < 0: - raise ValueError("Invalid value for `count`, must be a value greater than or equal to `0`") - - self._count = count - - @property - def records(self): - """ - Gets the records of this PaginatedDatasetResults. - - :return: The records of this PaginatedDatasetResults. - :rtype: list[DatasetSummaryResponse] - """ - return self._records - - @records.setter - def records(self, records): - """ - Sets the records of this PaginatedDatasetResults. - - :param records: The records of this PaginatedDatasetResults. - :type: list[DatasetSummaryResponse] - """ - if records is None: - raise ValueError("Invalid value for `records`, must not be `None`") - - self._records = records - - @property - def next_page_token(self): - """ - Gets the next_page_token of this PaginatedDatasetResults. - - :return: The next_page_token of this PaginatedDatasetResults. - :rtype: str - """ - return self._next_page_token - - @next_page_token.setter - def next_page_token(self, next_page_token): - """ - Sets the next_page_token of this PaginatedDatasetResults. - - :param next_page_token: The next_page_token of this PaginatedDatasetResults. - :type: str - """ - - self._next_page_token = next_page_token - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, PaginatedDatasetResults): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/paginated_insight_results.py b/datadotworld/client/_swagger/models/paginated_insight_results.py deleted file mode 100644 index 066eb47..0000000 --- a/datadotworld/client/_swagger/models/paginated_insight_results.py +++ /dev/null @@ -1,177 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class PaginatedInsightResults(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'count': 'int', - 'records': 'list[InsightSummaryResponse]', - 'next_page_token': 'str' - } - - attribute_map = { - 'count': 'count', - 'records': 'records', - 'next_page_token': 'nextPageToken' - } - - def __init__(self, count=None, records=None, next_page_token=None): - """ - PaginatedInsightResults - a model defined in Swagger - """ - - self._count = None - self._records = None - self._next_page_token = None - - self.count = count - self.records = records - if next_page_token is not None: - self.next_page_token = next_page_token - - @property - def count(self): - """ - Gets the count of this PaginatedInsightResults. - - :return: The count of this PaginatedInsightResults. - :rtype: int - """ - return self._count - - @count.setter - def count(self, count): - """ - Sets the count of this PaginatedInsightResults. - - :param count: The count of this PaginatedInsightResults. - :type: int - """ - if count is None: - raise ValueError("Invalid value for `count`, must not be `None`") - - self._count = count - - @property - def records(self): - """ - Gets the records of this PaginatedInsightResults. - - :return: The records of this PaginatedInsightResults. - :rtype: list[InsightSummaryResponse] - """ - return self._records - - @records.setter - def records(self, records): - """ - Sets the records of this PaginatedInsightResults. - - :param records: The records of this PaginatedInsightResults. - :type: list[InsightSummaryResponse] - """ - if records is None: - raise ValueError("Invalid value for `records`, must not be `None`") - - self._records = records - - @property - def next_page_token(self): - """ - Gets the next_page_token of this PaginatedInsightResults. - - :return: The next_page_token of this PaginatedInsightResults. - :rtype: str - """ - return self._next_page_token - - @next_page_token.setter - def next_page_token(self, next_page_token): - """ - Sets the next_page_token of this PaginatedInsightResults. - - :param next_page_token: The next_page_token of this PaginatedInsightResults. - :type: str - """ - - self._next_page_token = next_page_token - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, PaginatedInsightResults): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/paginated_project_results.py b/datadotworld/client/_swagger/models/paginated_project_results.py deleted file mode 100644 index da3b9a7..0000000 --- a/datadotworld/client/_swagger/models/paginated_project_results.py +++ /dev/null @@ -1,177 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class PaginatedProjectResults(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'count': 'int', - 'records': 'list[ProjectSummaryResponse]', - 'next_page_token': 'str' - } - - attribute_map = { - 'count': 'count', - 'records': 'records', - 'next_page_token': 'nextPageToken' - } - - def __init__(self, count=None, records=None, next_page_token=None): - """ - PaginatedProjectResults - a model defined in Swagger - """ - - self._count = None - self._records = None - self._next_page_token = None - - self.count = count - self.records = records - if next_page_token is not None: - self.next_page_token = next_page_token - - @property - def count(self): - """ - Gets the count of this PaginatedProjectResults. - - :return: The count of this PaginatedProjectResults. - :rtype: int - """ - return self._count - - @count.setter - def count(self, count): - """ - Sets the count of this PaginatedProjectResults. - - :param count: The count of this PaginatedProjectResults. - :type: int - """ - if count is None: - raise ValueError("Invalid value for `count`, must not be `None`") - - self._count = count - - @property - def records(self): - """ - Gets the records of this PaginatedProjectResults. - - :return: The records of this PaginatedProjectResults. - :rtype: list[ProjectSummaryResponse] - """ - return self._records - - @records.setter - def records(self, records): - """ - Sets the records of this PaginatedProjectResults. - - :param records: The records of this PaginatedProjectResults. - :type: list[ProjectSummaryResponse] - """ - if records is None: - raise ValueError("Invalid value for `records`, must not be `None`") - - self._records = records - - @property - def next_page_token(self): - """ - Gets the next_page_token of this PaginatedProjectResults. - - :return: The next_page_token of this PaginatedProjectResults. - :rtype: str - """ - return self._next_page_token - - @next_page_token.setter - def next_page_token(self, next_page_token): - """ - Sets the next_page_token of this PaginatedProjectResults. - - :param next_page_token: The next_page_token of this PaginatedProjectResults. - :type: str - """ - - self._next_page_token = next_page_token - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, PaginatedProjectResults): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/project_create_request.py b/datadotworld/client/_swagger/models/project_create_request.py deleted file mode 100644 index 42a7ead..0000000 --- a/datadotworld/client/_swagger/models/project_create_request.py +++ /dev/null @@ -1,347 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class ProjectCreateRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'title': 'str', - 'objective': 'str', - 'summary': 'str', - 'tags': 'list[str]', - 'license': 'str', - 'visibility': 'str', - 'files': 'list[FileCreateRequest]', - 'linked_datasets': 'list[LinkedDatasetCreateOrUpdateRequest]' - } - - attribute_map = { - 'title': 'title', - 'objective': 'objective', - 'summary': 'summary', - 'tags': 'tags', - 'license': 'license', - 'visibility': 'visibility', - 'files': 'files', - 'linked_datasets': 'linkedDatasets' - } - - def __init__(self, title=None, objective=None, summary=None, tags=None, license=None, visibility=None, files=None, linked_datasets=None): - """ - ProjectCreateRequest - a model defined in Swagger - """ - - self._title = None - self._objective = None - self._summary = None - self._tags = None - self._license = None - self._visibility = None - self._files = None - self._linked_datasets = None - - self.title = title - if objective is not None: - self.objective = objective - if summary is not None: - self.summary = summary - if tags is not None: - self.tags = tags - if license is not None: - self.license = license - self.visibility = visibility - if files is not None: - self.files = files - if linked_datasets is not None: - self.linked_datasets = linked_datasets - - @property - def title(self): - """ - Gets the title of this ProjectCreateRequest. - Project title. - - :return: The title of this ProjectCreateRequest. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this ProjectCreateRequest. - Project title. - - :param title: The title of this ProjectCreateRequest. - :type: str - """ - if title is None: - raise ValueError("Invalid value for `title`, must not be `None`") - if title is not None and len(title) > 60: - raise ValueError("Invalid value for `title`, length must be less than or equal to `60`") - if title is not None and len(title) < 0: - raise ValueError("Invalid value for `title`, length must be greater than or equal to `0`") - - self._title = title - - @property - def objective(self): - """ - Gets the objective of this ProjectCreateRequest. - Short project objective. - - :return: The objective of this ProjectCreateRequest. - :rtype: str - """ - return self._objective - - @objective.setter - def objective(self, objective): - """ - Sets the objective of this ProjectCreateRequest. - Short project objective. - - :param objective: The objective of this ProjectCreateRequest. - :type: str - """ - if objective is not None and len(objective) > 120: - raise ValueError("Invalid value for `objective`, length must be less than or equal to `120`") - if objective is not None and len(objective) < 0: - raise ValueError("Invalid value for `objective`, length must be greater than or equal to `0`") - - self._objective = objective - - @property - def summary(self): - """ - Gets the summary of this ProjectCreateRequest. - Long-form project summary (Markdown supported). - - :return: The summary of this ProjectCreateRequest. - :rtype: str - """ - return self._summary - - @summary.setter - def summary(self, summary): - """ - Sets the summary of this ProjectCreateRequest. - Long-form project summary (Markdown supported). - - :param summary: The summary of this ProjectCreateRequest. - :type: str - """ - if summary is not None and len(summary) > 25000: - raise ValueError("Invalid value for `summary`, length must be less than or equal to `25000`") - if summary is not None and len(summary) < 0: - raise ValueError("Invalid value for `summary`, length must be greater than or equal to `0`") - - self._summary = summary - - @property - def tags(self): - """ - Gets the tags of this ProjectCreateRequest. - Project tags. Letters numbers and spaces only (max 25 characters). - - :return: The tags of this ProjectCreateRequest. - :rtype: list[str] - """ - return self._tags - - @tags.setter - def tags(self, tags): - """ - Sets the tags of this ProjectCreateRequest. - Project tags. Letters numbers and spaces only (max 25 characters). - - :param tags: The tags of this ProjectCreateRequest. - :type: list[str] - """ - - self._tags = tags - - @property - def license(self): - """ - Gets the license of this ProjectCreateRequest. - Project license. Find additional info for allowed values [here](https://data.world/license-help). - - :return: The license of this ProjectCreateRequest. - :rtype: str - """ - return self._license - - @license.setter - def license(self, license): - """ - Sets the license of this ProjectCreateRequest. - Project license. Find additional info for allowed values [here](https://data.world/license-help). - - :param license: The license of this ProjectCreateRequest. - :type: str - """ - allowed_values = ["Public Domain", "PDDL", "CC-0", "CC-BY", "ODC-BY", "CC-BY-SA", "ODC-ODbL", "CC BY-NC", "CC BY-NC-SA", "Other"] - if license not in allowed_values: - raise ValueError( - "Invalid value for `license` ({0}), must be one of {1}" - .format(license, allowed_values) - ) - - self._license = license - - @property - def visibility(self): - """ - Gets the visibility of this ProjectCreateRequest. - Project visibility. `OPEN` if the project can be seen by any member of data.world. `PRIVATE` if the project can be seen by its owner and authorized collaborators. - - :return: The visibility of this ProjectCreateRequest. - :rtype: str - """ - return self._visibility - - @visibility.setter - def visibility(self, visibility): - """ - Sets the visibility of this ProjectCreateRequest. - Project visibility. `OPEN` if the project can be seen by any member of data.world. `PRIVATE` if the project can be seen by its owner and authorized collaborators. - - :param visibility: The visibility of this ProjectCreateRequest. - :type: str - """ - if visibility is None: - raise ValueError("Invalid value for `visibility`, must not be `None`") - allowed_values = ["OPEN", "PRIVATE"] - if visibility not in allowed_values: - raise ValueError( - "Invalid value for `visibility` ({0}), must be one of {1}" - .format(visibility, allowed_values) - ) - - self._visibility = visibility - - @property - def files(self): - """ - Gets the files of this ProjectCreateRequest. - Initial set of files. At project creation time, file uploads are not supported. However, this property can be used to add files from URL. - - :return: The files of this ProjectCreateRequest. - :rtype: list[FileCreateRequest] - """ - return self._files - - @files.setter - def files(self, files): - """ - Sets the files of this ProjectCreateRequest. - Initial set of files. At project creation time, file uploads are not supported. However, this property can be used to add files from URL. - - :param files: The files of this ProjectCreateRequest. - :type: list[FileCreateRequest] - """ - - self._files = files - - @property - def linked_datasets(self): - """ - Gets the linked_datasets of this ProjectCreateRequest. - Initial set of linked datasets. - - :return: The linked_datasets of this ProjectCreateRequest. - :rtype: list[LinkedDatasetCreateOrUpdateRequest] - """ - return self._linked_datasets - - @linked_datasets.setter - def linked_datasets(self, linked_datasets): - """ - Sets the linked_datasets of this ProjectCreateRequest. - Initial set of linked datasets. - - :param linked_datasets: The linked_datasets of this ProjectCreateRequest. - :type: list[LinkedDatasetCreateOrUpdateRequest] - """ - - self._linked_datasets = linked_datasets - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, ProjectCreateRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/project_patch_request.py b/datadotworld/client/_swagger/models/project_patch_request.py deleted file mode 100644 index 027f475..0000000 --- a/datadotworld/client/_swagger/models/project_patch_request.py +++ /dev/null @@ -1,345 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class ProjectPatchRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'title': 'str', - 'objective': 'str', - 'summary': 'str', - 'tags': 'list[str]', - 'license': 'str', - 'visibility': 'str', - 'files': 'list[FileCreateOrUpdateRequest]', - 'linked_datasets': 'list[LinkedDatasetCreateOrUpdateRequest]' - } - - attribute_map = { - 'title': 'title', - 'objective': 'objective', - 'summary': 'summary', - 'tags': 'tags', - 'license': 'license', - 'visibility': 'visibility', - 'files': 'files', - 'linked_datasets': 'linkedDatasets' - } - - def __init__(self, title=None, objective=None, summary=None, tags=None, license=None, visibility=None, files=None, linked_datasets=None): - """ - ProjectPatchRequest - a model defined in Swagger - """ - - self._title = None - self._objective = None - self._summary = None - self._tags = None - self._license = None - self._visibility = None - self._files = None - self._linked_datasets = None - - if title is not None: - self.title = title - if objective is not None: - self.objective = objective - if summary is not None: - self.summary = summary - if tags is not None: - self.tags = tags - if license is not None: - self.license = license - if visibility is not None: - self.visibility = visibility - if files is not None: - self.files = files - if linked_datasets is not None: - self.linked_datasets = linked_datasets - - @property - def title(self): - """ - Gets the title of this ProjectPatchRequest. - Project title. - - :return: The title of this ProjectPatchRequest. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this ProjectPatchRequest. - Project title. - - :param title: The title of this ProjectPatchRequest. - :type: str - """ - if title is not None and len(title) > 60: - raise ValueError("Invalid value for `title`, length must be less than or equal to `60`") - if title is not None and len(title) < 0: - raise ValueError("Invalid value for `title`, length must be greater than or equal to `0`") - - self._title = title - - @property - def objective(self): - """ - Gets the objective of this ProjectPatchRequest. - Short project objective. - - :return: The objective of this ProjectPatchRequest. - :rtype: str - """ - return self._objective - - @objective.setter - def objective(self, objective): - """ - Sets the objective of this ProjectPatchRequest. - Short project objective. - - :param objective: The objective of this ProjectPatchRequest. - :type: str - """ - if objective is not None and len(objective) > 120: - raise ValueError("Invalid value for `objective`, length must be less than or equal to `120`") - if objective is not None and len(objective) < 0: - raise ValueError("Invalid value for `objective`, length must be greater than or equal to `0`") - - self._objective = objective - - @property - def summary(self): - """ - Gets the summary of this ProjectPatchRequest. - Long-form project summary (Markdown supported). - - :return: The summary of this ProjectPatchRequest. - :rtype: str - """ - return self._summary - - @summary.setter - def summary(self, summary): - """ - Sets the summary of this ProjectPatchRequest. - Long-form project summary (Markdown supported). - - :param summary: The summary of this ProjectPatchRequest. - :type: str - """ - if summary is not None and len(summary) > 25000: - raise ValueError("Invalid value for `summary`, length must be less than or equal to `25000`") - if summary is not None and len(summary) < 0: - raise ValueError("Invalid value for `summary`, length must be greater than or equal to `0`") - - self._summary = summary - - @property - def tags(self): - """ - Gets the tags of this ProjectPatchRequest. - Project tags. Letters numbers and spaces only (max 25 characters). - - :return: The tags of this ProjectPatchRequest. - :rtype: list[str] - """ - return self._tags - - @tags.setter - def tags(self, tags): - """ - Sets the tags of this ProjectPatchRequest. - Project tags. Letters numbers and spaces only (max 25 characters). - - :param tags: The tags of this ProjectPatchRequest. - :type: list[str] - """ - - self._tags = tags - - @property - def license(self): - """ - Gets the license of this ProjectPatchRequest. - Project license. Find additional info for allowed values [here](https://data.world/license-help). - - :return: The license of this ProjectPatchRequest. - :rtype: str - """ - return self._license - - @license.setter - def license(self, license): - """ - Sets the license of this ProjectPatchRequest. - Project license. Find additional info for allowed values [here](https://data.world/license-help). - - :param license: The license of this ProjectPatchRequest. - :type: str - """ - allowed_values = ["Public Domain", "PDDL", "CC-0", "CC-BY", "ODC-BY", "CC-BY-SA", "ODC-ODbL", "CC BY-NC", "CC BY-NC-SA", "Other"] - if license not in allowed_values: - raise ValueError( - "Invalid value for `license` ({0}), must be one of {1}" - .format(license, allowed_values) - ) - - self._license = license - - @property - def visibility(self): - """ - Gets the visibility of this ProjectPatchRequest. - Project visibility. `OPEN` if the project can be seen by any member of data.world. `PRIVATE` if the project can be seen by its owner and authorized collaborators. - - :return: The visibility of this ProjectPatchRequest. - :rtype: str - """ - return self._visibility - - @visibility.setter - def visibility(self, visibility): - """ - Sets the visibility of this ProjectPatchRequest. - Project visibility. `OPEN` if the project can be seen by any member of data.world. `PRIVATE` if the project can be seen by its owner and authorized collaborators. - - :param visibility: The visibility of this ProjectPatchRequest. - :type: str - """ - allowed_values = ["OPEN", "PRIVATE"] - if visibility not in allowed_values: - raise ValueError( - "Invalid value for `visibility` ({0}), must be one of {1}" - .format(visibility, allowed_values) - ) - - self._visibility = visibility - - @property - def files(self): - """ - Gets the files of this ProjectPatchRequest. - Updated set of files. At project update time, file uploads are not supported. However, this property can be used to add files from URL or update metadata related to existing files. Files included in this request will be added. Previously added files will be preserved without modification. - - :return: The files of this ProjectPatchRequest. - :rtype: list[FileCreateOrUpdateRequest] - """ - return self._files - - @files.setter - def files(self, files): - """ - Sets the files of this ProjectPatchRequest. - Updated set of files. At project update time, file uploads are not supported. However, this property can be used to add files from URL or update metadata related to existing files. Files included in this request will be added. Previously added files will be preserved without modification. - - :param files: The files of this ProjectPatchRequest. - :type: list[FileCreateOrUpdateRequest] - """ - - self._files = files - - @property - def linked_datasets(self): - """ - Gets the linked_datasets of this ProjectPatchRequest. - Updated set of linked datasets. Datasets linked in this request will be added. Previously linked datasets will be preserved without modification. - - :return: The linked_datasets of this ProjectPatchRequest. - :rtype: list[LinkedDatasetCreateOrUpdateRequest] - """ - return self._linked_datasets - - @linked_datasets.setter - def linked_datasets(self, linked_datasets): - """ - Sets the linked_datasets of this ProjectPatchRequest. - Updated set of linked datasets. Datasets linked in this request will be added. Previously linked datasets will be preserved without modification. - - :param linked_datasets: The linked_datasets of this ProjectPatchRequest. - :type: list[LinkedDatasetCreateOrUpdateRequest] - """ - - self._linked_datasets = linked_datasets - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, ProjectPatchRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/project_put_request.py b/datadotworld/client/_swagger/models/project_put_request.py deleted file mode 100644 index 974137a..0000000 --- a/datadotworld/client/_swagger/models/project_put_request.py +++ /dev/null @@ -1,347 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class ProjectPutRequest(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'title': 'str', - 'objective': 'str', - 'summary': 'str', - 'tags': 'list[str]', - 'license': 'str', - 'visibility': 'str', - 'files': 'list[FileCreateRequest]', - 'linked_datasets': 'list[LinkedDatasetCreateOrUpdateRequest]' - } - - attribute_map = { - 'title': 'title', - 'objective': 'objective', - 'summary': 'summary', - 'tags': 'tags', - 'license': 'license', - 'visibility': 'visibility', - 'files': 'files', - 'linked_datasets': 'linkedDatasets' - } - - def __init__(self, title=None, objective=None, summary=None, tags=None, license=None, visibility=None, files=None, linked_datasets=None): - """ - ProjectPutRequest - a model defined in Swagger - """ - - self._title = None - self._objective = None - self._summary = None - self._tags = None - self._license = None - self._visibility = None - self._files = None - self._linked_datasets = None - - self.title = title - if objective is not None: - self.objective = objective - if summary is not None: - self.summary = summary - if tags is not None: - self.tags = tags - if license is not None: - self.license = license - self.visibility = visibility - if files is not None: - self.files = files - if linked_datasets is not None: - self.linked_datasets = linked_datasets - - @property - def title(self): - """ - Gets the title of this ProjectPutRequest. - Project title. - - :return: The title of this ProjectPutRequest. - :rtype: str - """ - return self._title - - @title.setter - def title(self, title): - """ - Sets the title of this ProjectPutRequest. - Project title. - - :param title: The title of this ProjectPutRequest. - :type: str - """ - if title is None: - raise ValueError("Invalid value for `title`, must not be `None`") - if title is not None and len(title) > 60: - raise ValueError("Invalid value for `title`, length must be less than or equal to `60`") - if title is not None and len(title) < 0: - raise ValueError("Invalid value for `title`, length must be greater than or equal to `0`") - - self._title = title - - @property - def objective(self): - """ - Gets the objective of this ProjectPutRequest. - Short project objective. - - :return: The objective of this ProjectPutRequest. - :rtype: str - """ - return self._objective - - @objective.setter - def objective(self, objective): - """ - Sets the objective of this ProjectPutRequest. - Short project objective. - - :param objective: The objective of this ProjectPutRequest. - :type: str - """ - if objective is not None and len(objective) > 120: - raise ValueError("Invalid value for `objective`, length must be less than or equal to `120`") - if objective is not None and len(objective) < 0: - raise ValueError("Invalid value for `objective`, length must be greater than or equal to `0`") - - self._objective = objective - - @property - def summary(self): - """ - Gets the summary of this ProjectPutRequest. - Long-form project summary (Markdown supported). - - :return: The summary of this ProjectPutRequest. - :rtype: str - """ - return self._summary - - @summary.setter - def summary(self, summary): - """ - Sets the summary of this ProjectPutRequest. - Long-form project summary (Markdown supported). - - :param summary: The summary of this ProjectPutRequest. - :type: str - """ - if summary is not None and len(summary) > 25000: - raise ValueError("Invalid value for `summary`, length must be less than or equal to `25000`") - if summary is not None and len(summary) < 0: - raise ValueError("Invalid value for `summary`, length must be greater than or equal to `0`") - - self._summary = summary - - @property - def tags(self): - """ - Gets the tags of this ProjectPutRequest. - Project tags. Letters numbers and spaces only (max 25 characters). - - :return: The tags of this ProjectPutRequest. - :rtype: list[str] - """ - return self._tags - - @tags.setter - def tags(self, tags): - """ - Sets the tags of this ProjectPutRequest. - Project tags. Letters numbers and spaces only (max 25 characters). - - :param tags: The tags of this ProjectPutRequest. - :type: list[str] - """ - - self._tags = tags - - @property - def license(self): - """ - Gets the license of this ProjectPutRequest. - Project license. Find additional info for allowed values [here](https://data.world/license-help). - - :return: The license of this ProjectPutRequest. - :rtype: str - """ - return self._license - - @license.setter - def license(self, license): - """ - Sets the license of this ProjectPutRequest. - Project license. Find additional info for allowed values [here](https://data.world/license-help). - - :param license: The license of this ProjectPutRequest. - :type: str - """ - allowed_values = ["Public Domain", "PDDL", "CC-0", "CC-BY", "ODC-BY", "CC-BY-SA", "ODC-ODbL", "CC BY-NC", "CC BY-NC-SA", "Other"] - if license not in allowed_values: - raise ValueError( - "Invalid value for `license` ({0}), must be one of {1}" - .format(license, allowed_values) - ) - - self._license = license - - @property - def visibility(self): - """ - Gets the visibility of this ProjectPutRequest. - Project visibility. `OPEN` if the project can be seen by any member of data.world. `PRIVATE` if the project can be seen by its owner and authorized collaborators. - - :return: The visibility of this ProjectPutRequest. - :rtype: str - """ - return self._visibility - - @visibility.setter - def visibility(self, visibility): - """ - Sets the visibility of this ProjectPutRequest. - Project visibility. `OPEN` if the project can be seen by any member of data.world. `PRIVATE` if the project can be seen by its owner and authorized collaborators. - - :param visibility: The visibility of this ProjectPutRequest. - :type: str - """ - if visibility is None: - raise ValueError("Invalid value for `visibility`, must not be `None`") - allowed_values = ["OPEN", "PRIVATE"] - if visibility not in allowed_values: - raise ValueError( - "Invalid value for `visibility` ({0}), must be one of {1}" - .format(visibility, allowed_values) - ) - - self._visibility = visibility - - @property - def files(self): - """ - Gets the files of this ProjectPutRequest. - Initial set of files. At project creation time, file uploads are not supported. However, this property can be used to add files from URL. - - :return: The files of this ProjectPutRequest. - :rtype: list[FileCreateRequest] - """ - return self._files - - @files.setter - def files(self, files): - """ - Sets the files of this ProjectPutRequest. - Initial set of files. At project creation time, file uploads are not supported. However, this property can be used to add files from URL. - - :param files: The files of this ProjectPutRequest. - :type: list[FileCreateRequest] - """ - - self._files = files - - @property - def linked_datasets(self): - """ - Gets the linked_datasets of this ProjectPutRequest. - Initial set of linked datasets. - - :return: The linked_datasets of this ProjectPutRequest. - :rtype: list[LinkedDatasetCreateOrUpdateRequest] - """ - return self._linked_datasets - - @linked_datasets.setter - def linked_datasets(self, linked_datasets): - """ - Sets the linked_datasets of this ProjectPutRequest. - Initial set of linked datasets. - - :param linked_datasets: The linked_datasets of this ProjectPutRequest. - :type: list[LinkedDatasetCreateOrUpdateRequest] - """ - - self._linked_datasets = linked_datasets - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, ProjectPutRequest): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/success_message.py b/datadotworld/client/_swagger/models/success_message.py deleted file mode 100644 index f92aedc..0000000 --- a/datadotworld/client/_swagger/models/success_message.py +++ /dev/null @@ -1,123 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class SuccessMessage(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'message': 'str' - } - - attribute_map = { - 'message': 'message' - } - - def __init__(self, message=None): - """ - SuccessMessage - a model defined in Swagger - """ - - self._message = None - - if message is not None: - self.message = message - - @property - def message(self): - """ - Gets the message of this SuccessMessage. - - :return: The message of this SuccessMessage. - :rtype: str - """ - return self._message - - @message.setter - def message(self, message): - """ - Sets the message of this SuccessMessage. - - :param message: The message of this SuccessMessage. - :type: str - """ - - self._message = message - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, SuccessMessage): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/user_data_response.py b/datadotworld/client/_swagger/models/user_data_response.py deleted file mode 100644 index 533f5ab..0000000 --- a/datadotworld/client/_swagger/models/user_data_response.py +++ /dev/null @@ -1,240 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class UserDataResponse(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'avatar_url': 'str', - 'display_name': 'str', - 'id': 'str', - 'created': 'str', - 'updated': 'str' - } - - attribute_map = { - 'avatar_url': 'avatarUrl', - 'display_name': 'displayName', - 'id': 'id', - 'created': 'created', - 'updated': 'updated' - } - - def __init__(self, avatar_url=None, display_name=None, id=None, created=None, updated=None): - """ - UserDataResponse - a model defined in Swagger - """ - - self._avatar_url = None - self._display_name = None - self._id = None - self._created = None - self._updated = None - - if avatar_url is not None: - self.avatar_url = avatar_url - if display_name is not None: - self.display_name = display_name - self.id = id - self.created = created - self.updated = updated - - @property - def avatar_url(self): - """ - Gets the avatar_url of this UserDataResponse. - URL of profile image. - - :return: The avatar_url of this UserDataResponse. - :rtype: str - """ - return self._avatar_url - - @avatar_url.setter - def avatar_url(self, avatar_url): - """ - Sets the avatar_url of this UserDataResponse. - URL of profile image. - - :param avatar_url: The avatar_url of this UserDataResponse. - :type: str - """ - - self._avatar_url = avatar_url - - @property - def display_name(self): - """ - Gets the display_name of this UserDataResponse. - User's name. - - :return: The display_name of this UserDataResponse. - :rtype: str - """ - return self._display_name - - @display_name.setter - def display_name(self, display_name): - """ - Sets the display_name of this UserDataResponse. - User's name. - - :param display_name: The display_name of this UserDataResponse. - :type: str - """ - - self._display_name = display_name - - @property - def id(self): - """ - Gets the id of this UserDataResponse. - User name and unique identifier. - - :return: The id of this UserDataResponse. - :rtype: str - """ - return self._id - - @id.setter - def id(self, id): - """ - Sets the id of this UserDataResponse. - User name and unique identifier. - - :param id: The id of this UserDataResponse. - :type: str - """ - if id is None: - raise ValueError("Invalid value for `id`, must not be `None`") - - self._id = id - - @property - def created(self): - """ - Gets the created of this UserDataResponse. - Date and time when account was created. - - :return: The created of this UserDataResponse. - :rtype: str - """ - return self._created - - @created.setter - def created(self, created): - """ - Sets the created of this UserDataResponse. - Date and time when account was created. - - :param created: The created of this UserDataResponse. - :type: str - """ - if created is None: - raise ValueError("Invalid value for `created`, must not be `None`") - - self._created = created - - @property - def updated(self): - """ - Gets the updated of this UserDataResponse. - Date and time when account was last updated. - - :return: The updated of this UserDataResponse. - :rtype: str - """ - return self._updated - - @updated.setter - def updated(self, updated): - """ - Sets the updated of this UserDataResponse. - Date and time when account was last updated. - - :param updated: The updated of this UserDataResponse. - :type: str - """ - if updated is None: - raise ValueError("Invalid value for `updated`, must not be `None`") - - self._updated = updated - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, UserDataResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/web_authorization.py b/datadotworld/client/_swagger/models/web_authorization.py deleted file mode 100644 index 13a4bac..0000000 --- a/datadotworld/client/_swagger/models/web_authorization.py +++ /dev/null @@ -1,164 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class WebAuthorization(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'type': 'str', - 'credentials': 'str' - } - - attribute_map = { - 'type': 'type', - 'credentials': 'credentials' - } - - def __init__(self, type=None, credentials=None): - """ - WebAuthorization - a model defined in Swagger - """ - - self._type = None - self._credentials = None - - self.type = type - if credentials is not None: - self.credentials = credentials - - @property - def type(self): - """ - Gets the type of this WebAuthorization. - The authorization scheme. Usually this is \"Bearer\" but it could be other values like \"Token\" or \"Basic\" etc. - - :return: The type of this WebAuthorization. - :rtype: str - """ - return self._type - - @type.setter - def type(self, type): - """ - Sets the type of this WebAuthorization. - The authorization scheme. Usually this is \"Bearer\" but it could be other values like \"Token\" or \"Basic\" etc. - - :param type: The type of this WebAuthorization. - :type: str - """ - if type is None: - raise ValueError("Invalid value for `type`, must not be `None`") - if type is not None and len(type) > 50: - raise ValueError("Invalid value for `type`, length must be less than or equal to `50`") - if type is not None and not re.search('[\\x21-\\x7E \\t]*', type): - raise ValueError("Invalid value for `type`, must be a follow pattern or equal to `/[\\x21-\\x7E \\t]*/`") - - self._type = type - - @property - def credentials(self): - """ - Gets the credentials of this WebAuthorization. - The confidential portion of the `Authorization` header that follows the `type` field. This field is write-only. It is omitted by read operations. If authorization is required, the `credentials` value must be provided whenever a File Source is created or modified. An update to a dataset that does not change the File Source may omit the `credentials` field--the update will preserve the previous value. - - :return: The credentials of this WebAuthorization. - :rtype: str - """ - return self._credentials - - @credentials.setter - def credentials(self, credentials): - """ - Sets the credentials of this WebAuthorization. - The confidential portion of the `Authorization` header that follows the `type` field. This field is write-only. It is omitted by read operations. If authorization is required, the `credentials` value must be provided whenever a File Source is created or modified. An update to a dataset that does not change the File Source may omit the `credentials` field--the update will preserve the previous value. - - :param credentials: The credentials of this WebAuthorization. - :type: str - """ - if credentials is not None and len(credentials) > 1024: - raise ValueError("Invalid value for `credentials`, length must be less than or equal to `1024`") - if credentials is not None and len(credentials) < 1: - raise ValueError("Invalid value for `credentials`, length must be greater than or equal to `1`") - if credentials is not None and not re.search('[\\x21-\\x7E \\t]*', credentials): - raise ValueError("Invalid value for `credentials`, must be a follow pattern or equal to `/[\\x21-\\x7E \\t]*/`") - - self._credentials = credentials - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, WebAuthorization): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/models/web_credentials.py b/datadotworld/client/_swagger/models/web_credentials.py deleted file mode 100644 index ab17b8c..0000000 --- a/datadotworld/client/_swagger/models/web_credentials.py +++ /dev/null @@ -1,158 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from pprint import pformat -from six import iteritems -import re - - -class WebCredentials(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - swagger_types = { - 'user': 'str', - 'password': 'str' - } - - attribute_map = { - 'user': 'user', - 'password': 'password' - } - - def __init__(self, user=None, password=None): - """ - WebCredentials - a model defined in Swagger - """ - - self._user = None - self._password = None - - self.user = user - if password is not None: - self.password = password - - @property - def user(self): - """ - Gets the user of this WebCredentials. - The name of the account to login to. - - :return: The user of this WebCredentials. - :rtype: str - """ - return self._user - - @user.setter - def user(self, user): - """ - Sets the user of this WebCredentials. - The name of the account to login to. - - :param user: The user of this WebCredentials. - :type: str - """ - if user is None: - raise ValueError("Invalid value for `user`, must not be `None`") - if user is not None and len(user) > 1024: - raise ValueError("Invalid value for `user`, length must be less than or equal to `1024`") - - self._user = user - - @property - def password(self): - """ - Gets the password of this WebCredentials. - The secret password. This field is write-only. It is omitted by read operations. If authorization is required, the `password` value must be provided whenever a File Source is created or modified. An update to a dataset that does not change the File Source may omit the `password` field--the update will preserve the previous value. - - :return: The password of this WebCredentials. - :rtype: str - """ - return self._password - - @password.setter - def password(self, password): - """ - Sets the password of this WebCredentials. - The secret password. This field is write-only. It is omitted by read operations. If authorization is required, the `password` value must be provided whenever a File Source is created or modified. An update to a dataset that does not change the File Source may omit the `password` field--the update will preserve the previous value. - - :param password: The password of this WebCredentials. - :type: str - """ - if password is not None and len(password) > 1024: - raise ValueError("Invalid value for `password`, length must be less than or equal to `1024`") - - self._password = password - - def to_dict(self): - """ - Returns the model properties as a dict - """ - result = {} - - for attr, _ in iteritems(self.swagger_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """ - Returns the string representation of the model - """ - return pformat(self.to_dict()) - - def __repr__(self): - """ - For `print` and `pprint` - """ - return self.to_str() - - def __eq__(self, other): - """ - Returns true if both objects are equal - """ - if not isinstance(other, WebCredentials): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other diff --git a/datadotworld/client/_swagger/rest.py b/datadotworld/client/_swagger/rest.py deleted file mode 100644 index 77bc5fd..0000000 --- a/datadotworld/client/_swagger/rest.py +++ /dev/null @@ -1,312 +0,0 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import io -import json -import ssl -import certifi -import logging -import re - -# python 2 and python 3 compatibility library -from six import PY3 -from six.moves.urllib.parse import urlencode - -from .configuration import Configuration - -try: - import urllib3 -except ImportError: - raise ImportError('Swagger python client requires urllib3.') - - -logger = logging.getLogger(__name__) - - -class RESTResponse(io.IOBase): - - def __init__(self, resp): - self.urllib3_response = resp - self.status = resp.status - self.reason = resp.reason - self.data = resp.data - - def getheaders(self): - """ - Returns a dictionary of the response headers. - """ - return self.urllib3_response.getheaders() - - def getheader(self, name, default=None): - """ - Returns a given response header. - """ - return self.urllib3_response.getheader(name, default) - - -class RESTClientObject(object): - - def __init__(self, pools_size=4, maxsize=4): - # urllib3.PoolManager will pass all kw parameters to connectionpool - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 - # maxsize is the number of requests to host that are allowed in parallel - # ca_certs vs cert_file vs key_file - # http://stackoverflow.com/a/23957365/2985775 - - # cert_reqs - if Configuration().verify_ssl: - cert_reqs = ssl.CERT_REQUIRED - else: - cert_reqs = ssl.CERT_NONE - - # ca_certs - if Configuration().ssl_ca_cert: - ca_certs = Configuration().ssl_ca_cert - else: - # if not set certificate file, use Mozilla's root certificates. - ca_certs = certifi.where() - - # cert_file - cert_file = Configuration().cert_file - - # key file - key_file = Configuration().key_file - - # proxy - proxy = Configuration().proxy - - # https pool manager - if proxy: - self.pool_manager = urllib3.ProxyManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=ca_certs, - cert_file=cert_file, - key_file=key_file, - proxy_url=proxy - ) - else: - self.pool_manager = urllib3.PoolManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=ca_certs, - cert_file=cert_file, - key_file=key_file - ) - - - def request(self, method, url, query_params=None, headers=None, - body=None, post_params=None, _preload_content=True, _request_timeout=None): - """ - :param method: http request method - :param url: http request url - :param query_params: query parameters in the url - :param headers: http request headers - :param body: request json body, for `application/json` - :param post_params: request post parameters, - `application/x-www-form-urlencoded` - and `multipart/form-data` - :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without - reading/decoding response data. Default is True. - :param _request_timeout: timeout setting for this request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) timeouts. - """ - method = method.upper() - assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS'] - - if post_params and body: - raise ValueError( - "body parameter cannot be used with post_params parameter." - ) - - post_params = post_params or {} - headers = headers or {} - - timeout = None - if _request_timeout: - if isinstance(_request_timeout, (int, ) if PY3 else (int, long)): - timeout = urllib3.Timeout(total=_request_timeout) - elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: - timeout = urllib3.Timeout(connect=_request_timeout[0], read=_request_timeout[1]) - - if 'Content-Type' not in headers: - headers['Content-Type'] = 'application/json' - - try: - # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` - if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: - if query_params: - url += '?' + urlencode(query_params) - if re.search('json', headers['Content-Type'], re.IGNORECASE): - request_body = None - if body: - request_body = json.dumps(body) - r = self.pool_manager.request(method, url, - body=request_body, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'application/x-www-form-urlencoded': - r = self.pool_manager.request(method, url, - fields=post_params, - encode_multipart=False, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'multipart/form-data': - # must del headers['Content-Type'], or the correct Content-Type - # which generated by urllib3 will be overwritten. - del headers['Content-Type'] - r = self.pool_manager.request(method, url, - fields=post_params, - encode_multipart=True, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - # Pass a `string` parameter directly in the body to support - # other content types than Json when `body` argument is provided - # in serialized form - elif isinstance(body, str): - request_body = body - r = self.pool_manager.request(method, url, - body=request_body, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - else: - # Cannot generate the request from given parameters - msg = """Cannot prepare a request message for provided arguments. - Please check that your arguments match declared content type.""" - raise ApiException(status=0, reason=msg) - # For `GET`, `HEAD` - else: - r = self.pool_manager.request(method, url, - fields=query_params, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - except urllib3.exceptions.SSLError as e: - msg = "{0}\n{1}".format(type(e).__name__, str(e)) - raise ApiException(status=0, reason=msg) - - if _preload_content: - r = RESTResponse(r) - - # In the python 3, the response.data is bytes. - # we need to decode it to string. - if PY3: - r.data = r.data.decode('utf8') - - # log response body - logger.debug("response body: %s", r.data) - - if not 200 <= r.status <= 299: - raise ApiException(http_resp=r) - - return r - - def GET(self, url, headers=None, query_params=None, _preload_content=True, _request_timeout=None): - return self.request("GET", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params) - - def HEAD(self, url, headers=None, query_params=None, _preload_content=True, _request_timeout=None): - return self.request("HEAD", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params) - - def OPTIONS(self, url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, - _request_timeout=None): - return self.request("OPTIONS", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def DELETE(self, url, headers=None, query_params=None, body=None, _preload_content=True, _request_timeout=None): - return self.request("DELETE", url, - headers=headers, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def POST(self, url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, - _request_timeout=None): - return self.request("POST", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def PUT(self, url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, - _request_timeout=None): - return self.request("PUT", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def PATCH(self, url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, - _request_timeout=None): - return self.request("PATCH", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - -class ApiException(Exception): - - def __init__(self, status=None, reason=None, http_resp=None): - if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data - self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None - - def __str__(self): - """ - Custom error messages for exception - """ - error_message = "({0})\n"\ - "Reason: {1}\n".format(self.status, self.reason) - if self.headers: - error_message += "HTTP response headers: {0}\n".format(self.headers) - - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) - - return error_message diff --git a/datadotworld/client/api.py b/datadotworld/client/api.py index 63cb105..7f7b240 100644 --- a/datadotworld/client/api.py +++ b/datadotworld/client/api.py @@ -19,23 +19,10 @@ from __future__ import absolute_import, division -import functools -import glob import json -import os -import shutil -import uuid -import zipfile -from os import path - import requests -import six -from datadotworld.client import _swagger -from datadotworld.client.content_negotiating_api_client import ( - ContentNegotiatingApiClient -) -from datadotworld.util import parse_dataset_key, _user_agent +from .api_client import ApiClient class RestApiClient(object): @@ -49,1364 +36,7 @@ def __init__(self, config): self._config = config self._protocol = 'https' self._download_host = 'download.data.world' - - api_host = 'api.data.world' - self._host = "{}://{}/v0".format(self._protocol, api_host) - swagger_client = _swagger.ApiClient( - host=self._host, - header_name='Authorization', - header_value='Bearer {}'.format(self._config.auth_token)) - swagger_client.user_agent = _user_agent() - - self._build_api_client = functools.partial( - ContentNegotiatingApiClient, - host=self._host, - header_name='Authorization', - header_value='Bearer {}'.format(self._config.auth_token), - user_agent=_user_agent()) - - self._datasets_api = _swagger.DatasetsApi(swagger_client) - self._uploads_api = _swagger.UploadsApi(swagger_client) - self._user_api = _swagger.UserApi(swagger_client) - self._download_api = _swagger.DownloadApi(swagger_client) - self._streams_api = _swagger.StreamsApi(swagger_client) - self._projects_api = _swagger.ProjectsApi(swagger_client) - self._insights_api = _swagger.InsightsApi(swagger_client) - - # Dataset Operations - - def get_dataset(self, dataset_key): - """Retrieve an existing dataset definition - - This method retrieves metadata about an existing - - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :returns: Dataset definition, with all attributes - :rtype: dict - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> intro_dataset = api_client.get_dataset( - ... 'jonloyens/an-intro-to-dataworld-dataset') # doctest: +SKIP - >>> intro_dataset['title'] # doctest: +SKIP - 'An Intro to data.world Dataset' - """ - try: - return self._datasets_api.get_dataset( - *(parse_dataset_key(dataset_key))).to_dict() - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def create_dataset(self, owner_id, **kwargs): - """Create a new dataset - - :param owner_id: Username of the owner of the new dataset - :type owner_id: str - :param title: Dataset title (will be used to generate dataset id on - creation) - :type title: str - :param description: Dataset description - :type description: str, optional - :param summary: Dataset summary markdown - :type summary: str, optional - :param tags: Dataset tags - :type tags: list, optional - :param license: Dataset license - :type license: {'Public Domain', 'PDDL', 'CC-0', 'CC-BY', 'ODC-BY', - 'CC-BY-SA', 'ODC-ODbL', 'CC BY-NC', 'CC BY-NC-SA', 'Other'} - :param visibility: Dataset visibility - :type visibility: {'OPEN', 'PRIVATE'} - :param files: File name as dict, source URLs, description and labels() - as properties - :type files: dict, optional - *Description and labels are optional* - :returns: Newly created dataset key - :rtype: str - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> url = 'http://www.acme.inc/example.csv' - >>> api_client.create_dataset( - ... 'username', title='Test dataset', visibility='PRIVATE', - ... license='Public Domain', - ... files={'dataset.csv':{'url': url}}) # doctest: +SKIP - """ - request = self.__build_dataset_obj( - lambda: _swagger.DatasetCreateRequest( - title=kwargs.get('title'), - visibility=kwargs.get('visibility')), - lambda name, url, expand_archive, description, labels: - _swagger.FileCreateRequest( - name=name, - source=_swagger.FileSourceCreateRequest( - url=url, - expand_archive=expand_archive), - description=description, - labels=labels), - kwargs) - try: - (_, _, headers) = self._datasets_api.create_dataset_with_http_info( - owner_id, request, _return_http_data_only=False) - if 'Location' in headers: - return headers['Location'] - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def update_dataset(self, dataset_key, **kwargs): - """Update an existing dataset - - :param description: Dataset description - :type description: str, optional - :param summary: Dataset summary markdown - :type summary: str, optional - :param tags: Dataset tags - :type tags: list, optional - :param license: Dataset license - :type license: {'Public Domain', 'PDDL', 'CC-0', 'CC-BY', 'ODC-BY', - 'CC-BY-SA', 'ODC-ODbL', 'CC BY-NC', 'CC BY-NC-SA', 'Other'} - :param visibility: Dataset visibility - :type visibility: {'OPEN', 'PRIVATE'}, optional - :param files: File names and source URLs to add or update - :type files: dict, optional - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.update_dataset( - ... 'username/test-dataset', - ... tags=['demo', 'datadotworld']) # doctest: +SKIP - """ - request = self.__build_dataset_obj( - lambda: _swagger.DatasetPatchRequest(), - lambda name, url, expand_archive, description, labels: - _swagger.FileCreateOrUpdateRequest( - name=name, - source=_swagger.FileSourceCreateOrUpdateRequest( - url=url, - expand_archive=expand_archive) - if url is not None else None, - description=description, - labels=labels), - kwargs) - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - self._datasets_api.patch_dataset(owner_id, dataset_id, request) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def replace_dataset(self, dataset_key, **kwargs): - """Replace an existing dataset - - *This method will completely overwrite an existing dataset.* - - :param description: Dataset description - :type description: str, optional - :param summary: Dataset summary markdown - :type summary: str, optional - :param tags: Dataset tags - :type tags: list, optional - :param license: Dataset license - :type license: {'Public Domain', 'PDDL', 'CC-0', 'CC-BY', 'ODC-BY', - 'CC-BY-SA', 'ODC-ODbL', 'CC BY-NC', 'CC BY-NC-SA', 'Other'} - :param visibility: Dataset visibility - :type visibility: {'OPEN', 'PRIVATE'} - :param files: File names and source URLs to add or update - :type files: dict, optional - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.replace_dataset( - ... 'username/test-dataset', - ... visibility='PRIVATE', license='Public Domain', - ... description='A better description') # doctest: +SKIP - """ - request = self.__build_dataset_obj( - lambda: _swagger.DatasetPutRequest( - title=kwargs.get('title'), - visibility=kwargs.get('visibility') - ), - lambda name, url, expand_archive, description, labels: - _swagger.FileCreateRequest( - name=name, - source=_swagger.FileSourceCreateRequest( - url=url, - expand_archive=expand_archive), - description=description, - labels=labels), - kwargs) - - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - self._datasets_api.replace_dataset(owner_id, dataset_id, request) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def delete_dataset(self, dataset_key): - """Deletes a dataset and all associated data - - :params dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.delete_dataset( - ... 'username/dataset') # doctest: +SKIP - """ - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - self._datasets_api.delete_dataset(owner_id, dataset_id) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - # File Operations - - def add_files_via_url(self, dataset_key, files={}): - """Add or update dataset files linked to source URLs - - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :param files: Dict containing the name of files and metadata - Uses file name as a dict containing File description, labels and - source URLs to add or update (Default value = {}) - *description and labels are optional.* - :type files: dict - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> url = 'http://www.acme.inc/example.csv' - >>> api_client = dw.api_client() - >>> api_client.add_files_via_url( - ... 'username/test-dataset', - ... {'example.csv': { - ... 'url': url, - ... 'labels': ['raw data'], - ... 'description': 'file description'}}) # doctest: +SKIP - """ - file_requests = [_swagger.FileCreateOrUpdateRequest( - name=file_name, - source=_swagger.FileSourceCreateOrUpdateRequest( - url=file_info['url'], - expand_archive=file_info.get('expand_archive', - False)), - description=file_info.get('description'), - labels=file_info.get('labels'), - ) for file_name, file_info in files.items()] - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - self._datasets_api.add_files_by_source( - owner_id, dataset_id, - _swagger.FileBatchUpdateRequest(files=file_requests)) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def sync_files(self, dataset_key): - """Trigger synchronization process to update all dataset files linked to - source URLs. - - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.sync_files('username/test-dataset') # doctest: +SKIP - """ - try: - self._datasets_api.sync(*(parse_dataset_key(dataset_key))) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def upload_files(self, dataset_key, files, files_metadata={}, **kwargs): - """Upload dataset files - - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :param files: The list of names/paths for files stored in the - local filesystem - :type files: list of str - :param expand_archives: Boolean value to indicate files should be - expanded upon upload - :type expand_archive: bool optional - :param files_metadata: Dict containing the name of files and metadata - Uses file name as a dict containing File description, labels and - source URLs to add or update - :type files_metadata: dict optional - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.upload_files( - ... 'username/test-dataset', - ... ['/my/local/example.csv']) # doctest: +SKIP - """ - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - self._uploads_api.upload_files(owner_id, dataset_id, files, - **kwargs) - if files_metadata: - self.update_dataset(dataset_key, files=files_metadata) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def upload_file(self, dataset_key, name, file_metadata={}, **kwargs): - """Upload one file to a dataset - - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :param name: Name/path for files stored in the local filesystem - :type name: str - :param expand_archives: Boolean value to indicate files should be - expanded upon upload - :type expand_archive: bool optional - :param files_metadata: Dict containing the name of files and metadata - Uses file name as a dict containing File description, labels and - source URLs to add or update - :type files_metadata: dict optional - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.upload_file( - ... 'username/test-dataset', - ... 'example.csv') # doctest: +SKIP - """ - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - self._uploads_api.upload_file(owner_id, dataset_id, name, **kwargs) - if file_metadata: - self.update_dataset(dataset_key, files=file_metadata) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def delete_files(self, dataset_key, names): - """Delete dataset file(s) - - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :param names: The list of names for files to be deleted - :type names: list of str - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.delete_files( - ... 'username/test-dataset', ['example.csv']) # doctest: +SKIP - """ - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - self._datasets_api.delete_files_and_sync_sources( - owner_id, dataset_id, names) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - # Datapackage - - def download_datapackage(self, dataset_key, dest_dir): - """Download and unzip a dataset's datapackage - - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :param dest_dir: Directory under which datapackage should be saved - :type dest_dir: str or path - :returns: Location of the datapackage descriptor (datapackage.json) in - the local filesystem - :rtype: path - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> datapackage_descriptor = api_client.download_datapackage( - ... 'jonloyens/an-intro-to-dataworld-dataset', - ... '/tmp/test') # doctest: +SKIP - >>> datapackage_descriptor # doctest: +SKIP - '/tmp/test/datapackage.json' - """ - if path.isdir(dest_dir): - raise ValueError('dest_dir must be a new directory, ' - 'but {} already exists'.format(dest_dir)) - - owner_id, dataset_id = parse_dataset_key(dataset_key) - url = "{0}://{1}/datapackage/{2}/{3}".format( - self._protocol, self._download_host, owner_id, dataset_id) - headers = { - 'User-Agent': _user_agent(), - 'Authorization': 'Bearer {0}'.format(self._config.auth_token) - } - - try: - response = requests.get(url, headers=headers, stream=True) - response.raise_for_status() - except requests.RequestException as e: - raise RestApiError(cause=e) - - unzip_dir = path.join(self._config.tmp_dir, str(uuid.uuid4())) - os.makedirs(unzip_dir) - - zip_file = path.join(unzip_dir, 'dataset.zip') - - with open(zip_file, 'wb') as f: - for data in response.iter_content(chunk_size=4096): - f.write(data) - - zip_obj = zipfile.ZipFile(zip_file) - zip_obj.extractall(path=unzip_dir) - - # Find where datapackage.json is within expanded files - unzipped_descriptor = glob.glob( - '{}/**/datapackage.json'.format(unzip_dir)) - if not unzipped_descriptor: - raise RuntimeError( - 'Zip file did not contain a datapackage manifest.') - - unzipped_dir = path.dirname(unzipped_descriptor[0]) - - shutil.move(unzipped_dir, dest_dir) - shutil.rmtree(unzip_dir, ignore_errors=True) - - return path.join(dest_dir, 'datapackage.json') - - # User Operations - - def get_user_data(self): - """Retrieve data for authenticated user - - :returns: User data, with all attributes - :rtype: dict - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> user_data = api_client.get_user_data() # doctest: +SKIP - >>> user_data[display_name] # doctest: +SKIP - 'Name User' - """ - try: - return self._user_api.get_user_data().to_dict() - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def fetch_contributing_datasets(self, **kwargs): - """Fetch datasets that the authenticated user has access to - - :param limit: Maximum number of items to include in a page of results - :type limit: str, optional - :param next: Token from previous result page (to be used when - requesting a subsequent page) - :type next: str, optional - :param sort: Property name to sort - :type sort: str, optional - :returns: Authenticated user dataset - :rtype: dict - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> user_dataset = - ... api_client.fetch_contributing_datasets() # doctest: +SKIP - {'count': 0, 'records': [], 'next_page_token': None} - """ - try: - return self._user_api.fetch_contributing_datasets( - **kwargs).to_dict() - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def fetch_liked_datasets(self, **kwargs): - """Fetch datasets that authenticated user likes - - :param limit: Maximum number of items to include in a page of results - :type limit: str, optional - :param next: Token from previous result page (to be used when - requesting a subsequent page) - :type next: str, optional - :param sort: Property name to sort - :type sort: str, optional - :returns: Dataset definition, with all attributes - :rtype: dict - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> user_liked_dataset = - ... api_client.fetch_liked_datasets() # doctest: +SKIP - """ - try: - return self._user_api.fetch_liked_datasets(**kwargs).to_dict() - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def fetch_datasets(self, **kwargs): - """Fetch authenticated user owned datasets - - :param limit: Maximum number of items to include in a page of results - :type limit: str, optional - :param next: Token from previous result page (to be used when - requesting a subsequent page) - :type next: str, optional - :param sort: Property name to sort - :type sort: str, optional - :returns: Dataset definition, with all attributes - :rtype: dict - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> user_owned_dataset = api_client.fetch_datasets() # doctest: +SKIP - """ - try: - return self._user_api.fetch_datasets(**kwargs).to_dict() - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def fetch_contributing_projects(self, **kwargs): - """Fetch projects that the currently authenticated user has access to - - :returns: Authenticated user projects - :rtype: dict - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> user_projects = - ... api_client.fetch_contributing_projects() # doctest: +SKIP - {'count': 0, 'records': [], 'next_page_token': None} - """ - try: - return self._user_api.fetch_contributing_projects( - **kwargs).to_dict() - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def fetch_liked_projects(self, **kwargs): - """Fetch projects that the currently authenticated user likes - - :returns: Authenticated user projects - :rtype: dict - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> user_liked_projects = - ... api_client.fetch_liked_projects() # doctest: +SKIP - """ - try: - return self._user_api.fetch_liked_projects(**kwargs).to_dict() - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def fetch_projects(self, **kwargs): - """Fetch projects that the currently authenticated user owns - - :returns: Authenticated user projects - :rtype: dict - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> user_projects = - ... api_client.fetch_projects() # doctest: +SKIP - """ - try: - return self._user_api.fetch_projects(**kwargs).to_dict() - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - # Sql Operations - - def sql(self, dataset_key, query, desired_mimetype='application/json', - **kwargs): - """Executes SQL queries against a dataset via POST - - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :param query: SQL query - :type query: str - :param include_table_schema: Flags indicating to include table schema - in the response - :type include_table_schema: bool - :returns: file object that can be used in file parsers and - data handling modules. - :rtype: file-like object - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.sql('username/test-dataset', 'query') # doctest: +SKIP - """ - api_client = self._build_api_client( - default_mimetype_header_accept=desired_mimetype) - sql_api = kwargs.get('sql_api_mock', _swagger.SqlApi(api_client)) - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - response = sql_api.sql_post( - owner_id, dataset_id, query, _preload_content=False, **kwargs) - return six.BytesIO(response.data) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - # Sparql Operations - - def sparql(self, dataset_key, query, - desired_mimetype='application/sparql-results+json', **kwargs): - """Executes SPARQL queries against a dataset via POST - - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :param query: SPARQL query - :type query: str - :returns: file object that can be used in file parsers and - data handling modules. - :rtype: file object - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.sparql_post('username/test-dataset', - ... query) # doctest: +SKIP - """ - api_client = self._build_api_client( - default_mimetype_header_accept=desired_mimetype) - sparql_api = kwargs.get('sparql_api_mock', - _swagger.SparqlApi(api_client)) - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - response = sparql_api.sparql_post( - owner_id, dataset_id, query, _preload_content=False, **kwargs) - return six.BytesIO(response.data) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - # Download Operations - - def download_dataset(self, dataset_key): - """Return a .zip containing all files within the dataset as uploaded. - - :param dataset_key : Dataset identifier, in the form of owner/id - :type dataset_key: str - :returns: .zip file contain files within dataset - :rtype: file object - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.download_dataset( - ... 'username/test-dataset') # doctest: +SKIP - """ - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - return self._download_api.download_dataset(owner_id, dataset_id) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def download_file(self, dataset_key, file): - """Return a file within the dataset as uploaded. - - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :param file: File path to be returned - :type file: str - :returns: file in which the data was uploaded - :rtype: file object - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.download_file('username/test-dataset', - ... '/my/local/example.csv') # doctest: +SKIP - """ - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - return self._download_api.download_file(owner_id, dataset_id, file) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - # Streams Operation - - def append_records(self, dataset_key, stream_id, body): - """Append records to a stream. - - :param dataset_key: Dataset identifier, in the form of owner/id - :type dataset_key: str - :param stream_id: Stream unique identifier. - :type stream_id: str - :param body: Object body - :type body: obj - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.append_records('username/test-dataset','streamId', - ... {'content':'content'}) # doctest: +SKIP - """ - owner_id, dataset_id = parse_dataset_key(dataset_key) - try: - return self._streams_api.append_records(owner_id, dataset_id, - stream_id, body) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - # Projects Operations - - def get_project(self, project_key): - """Retrieve an existing project - - This method retrieves metadata about an existing project - - :param project_key: Project identifier, in the form of owner/id - :type project_key: str - :returns: Project definition, with all attributes - :rtype: dict - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> intro_project = api_client.get_project( - ... 'jonloyens/' - ... 'an-example-project-that-shows-what-to-put-in-data-world' - ... ) # doctest: +SKIP - >>> intro_project['title'] # doctest: +SKIP - 'An Example Project that Shows What To Put in data.world' - """ - try: - owner_id, project_id = parse_dataset_key(project_key) - return self._projects_api.get_project(owner_id, - project_id).to_dict() - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def create_project(self, owner_id, **kwargs): - """Create a new project - - :param owner_id: Username of the creator of a - project. - :type owner_id: str - :param title: Project title (will be used to generate project id on - creation) - :type title: str - :param objective: Short project objective. - :type objective: str, optional - :param summary: Long-form project summary. - :type summary: str, optional - :param tags: Project tags. Letters numbers and spaces - :type tags: list, optional - :param license: Project license - :type license: {'Public Domain', 'PDDL', 'CC-0', 'CC-BY', 'ODC-BY', - 'CC-BY-SA', 'ODC-ODbL', 'CC BY-NC', 'CC BY-NC-SA', 'Other'} - :param visibility: Project visibility - :type visibility: {'OPEN', 'PRIVATE'} - :param files: File name as dict, source URLs, description and labels() - as properties - :type files: dict, optional - *Description and labels are optional* - :param linked_datasets: Initial set of linked datasets. - :type linked_datasets: list of object, optional - :returns: Newly created project key - :rtype: str - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.create_project( - ... 'username', title='project testing', - ... visibility='PRIVATE', - ... linked_datasets=[{'owner': 'someuser', - ... 'id': 'somedataset'}]) # doctest: +SKIP - """ - request = self.__build_project_obj( - lambda: _swagger.ProjectCreateRequest( - title=kwargs.get('title'), - visibility=kwargs.get('visibility') - ), - lambda name, url, description, labels: - _swagger.FileCreateRequest( - name=name, - source=_swagger.FileSourceCreateRequest(url=url), - description=description, - labels=labels), kwargs) - try: - (_, _, headers) = self._projects_api.create_project_with_http_info( - owner_id, body=request, _return_http_data_only=False) - if 'Location' in headers: - return headers['Location'] - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def update_project(self, project_key, **kwargs): - """Update an existing project - - :param project_key: Username and unique identifier of the creator of a - project in the form of owner/id. - :type project_key: str - :param title: Project title - :type title: str - :param objective: Short project objective. - :type objective: str, optional - :param summary: Long-form project summary. - :type summary: str, optional - :param tags: Project tags. Letters numbers and spaces - :type tags: list, optional - :param license: Project license - :type license: {'Public Domain', 'PDDL', 'CC-0', 'CC-BY', 'ODC-BY', - 'CC-BY-SA', 'ODC-ODbL', 'CC BY-NC', 'CC BY-NC-SA', 'Other'} - :param visibility: Project visibility - :type visibility: {'OPEN', 'PRIVATE'} - :param files: File name as dict, source URLs, description and labels() - as properties - :type files: dict, optional - *Description and labels are optional* - :param linked_datasets: Initial set of linked datasets. - :type linked_datasets: list of object, optional - :returns: message object - :rtype: object - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.update_project( - ... 'username/test-project', - ... tags=['demo', 'datadotworld']) # doctest: +SKIP - """ - request = self.__build_project_obj( - lambda: _swagger.ProjectPatchRequest(), - lambda name, url, description, labels: - _swagger.FileCreateOrUpdateRequest( - name=name, - source=_swagger.FileSourceCreateOrUpdateRequest(url=url), - description=description, - labels=labels), - kwargs) - owner_id, project_id = parse_dataset_key(project_key) - try: - return self._projects_api.patch_project(owner_id, - project_id, - body=request) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def replace_project(self, project_key, **kwargs): - """Replace an existing Project - - *Create a project with a given id or completely rewrite the project, - including any previously added files or linked datasets, if one already - exists with the given id.* - - :param project_key: Username and unique identifier of the creator of a - project in the form of owner/id. - :type project_key: str - :param title: Project title - :type title: str - :param objective: Short project objective. - :type objective: str, optional - :param summary: Long-form project summary. - :type summary: str, optional - :param tags: Project tags. Letters numbers and spaces - :type tags: list, optional - :param license: Project license - :type license: {'Public Domain', 'PDDL', 'CC-0', 'CC-BY', 'ODC-BY', - 'CC-BY-SA', 'ODC-ODbL', 'CC BY-NC', 'CC BY-NC-SA', 'Other'} - :param visibility: Project visibility - :type visibility: {'OPEN', 'PRIVATE'} - :param files: File name as dict, source URLs, description and labels() - as properties - :type files: dict, optional - *Description and labels are optional* - :param linked_datasets: Initial set of linked datasets. - :type linked_datasets: list of object, optional - :returns: project object - :rtype: object - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.replace_project( - ... 'username/test-project', - ... visibility='PRIVATE', - ... objective='A better objective', - ... title='Replace project') # doctest: +SKIP - """ - request = self.__build_project_obj( - lambda: _swagger.ProjectCreateRequest( - title=kwargs.get('title'), - visibility=kwargs.get('visibility') - ), - lambda name, url, description, labels: - _swagger.FileCreateRequest( - name=name, - source=_swagger.FileSourceCreateRequest(url=url), - description=description, - labels=labels), - kwargs) - try: - project_owner_id, project_id = parse_dataset_key(project_key) - self._projects_api.replace_project(project_owner_id, - project_id, - body=request) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def add_linked_dataset(self, project_key, dataset_key): - """Link project to an existing dataset - - This method links a dataset to project - - :param project_key: Project identifier, in the form of owner/id - :type project_key: str - :param dataset_key: Dataset identifier, in the form of owner/id - :type project_key: str - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> linked_dataset = api_client.add_linked_dataset( - ... 'username/test-project', - ... 'username/test-dataset') # doctest: +SKIP - """ - try: - project_owner_id, project_id = parse_dataset_key(project_key) - dataset_owner_id, dataset_id = parse_dataset_key(dataset_key) - self._projects_api.add_linked_dataset(project_owner_id, - project_id, - dataset_owner_id, - dataset_id) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def remove_linked_dataset(self, project_key, dataset_key): - """Unlink dataset - - This method unlinks a dataset from a project - - :param project_key: Project identifier, in the form of owner/id - :type project_key: str - :param dataset_key: Dataset identifier, in the form of owner/id - :type project_key: str - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.remove_linked_dataset( - ... 'username/test-project', - ... 'username/test-dataset') # doctest: +SKIP - """ - try: - project_owner_id, project_id = parse_dataset_key(project_key) - dataset_owner_id, dataset_id = parse_dataset_key(dataset_key) - self._projects_api.remove_linked_dataset(project_owner_id, - project_id, - dataset_owner_id, - dataset_id) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def delete_project(self, project_key): - """Deletes a project and all associated data - - :params project_key: Project identifier, in the form of owner/id - :type project_key: str - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.delete_project( - ... 'username/test-project') # doctest: +SKIP - """ - owner_id, project_id = parse_dataset_key(project_key) - try: - self._projects_api.delete_project(owner_id, project_id) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - # Insight Operations - - def get_insight(self, project_key, insight_id, **kwargs): - """Retrieve an insight - - :param project_key: Project identifier, in the form of - projectOwner/projectid - :type project_key: str - :param insight_id: Insight unique identifier. - :type insight_id: str - :returns: Insight definition, with all attributes - :rtype: object - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> insight = api_client.get_insight( - ... 'jonloyens/' - ... 'an-example-project-that-shows-what-to-put-in-data-world', - ... 'c2538b0c-c200-474c-9631-5ff4f13026eb') # doctest: +SKIP - >>> insight['title'] # doctest: +SKIP - 'Coast Guard Lives Saved by Fiscal Year' - """ - try: - project_owner, project_id = parse_dataset_key(project_key) - return self._insights_api.get_insight(project_owner, - project_id, - insight_id, - **kwargs).to_dict() - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def get_insights_for_project(self, project_key, **kwargs): - """Get insights for a project. - - :param project_key: Project identifier, in the form of - projectOwner/projectid - :type project_key: str - :returns: Insight results - :rtype: object - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> insights = api_client.get_insights_for_project( - ... 'jonloyens/' - ... 'an-example-project-that-shows-what-to-put-in-data-world' - ... ) # doctest: +SKIP - """ - try: - project_owner, project_id = parse_dataset_key(project_key) - return self._insights_api.get_insights_for_project(project_owner, - project_id, - **kwargs) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def create_insight(self, project_key, **kwargs): - """Create a new insight - - :param project_key: Project identifier, in the form of - projectOwner/projectid - :type project_key: str - :param title: Insight title - :type title: str - :param description: Insight description. - :type description: str, optional - :param image_url: If image-based, the URL of the image - :type image_url: str - :param embed_url: If embed-based, the embeddable URL - :type embed_url: str - :param source_link: Permalink to source code or platform this insight - was generated with. Allows others to replicate the steps originally - used to produce the insight. - :type source_link: str, optional - :param data_source_links: One or more permalinks to the data sources - used to generate this insight. Allows others to access the data - originally used to produce the insight. - :type data_source_links: array - :returns: Insight with message and uri object - :rtype: object - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.create_insight( - ... 'projectOwner/projectid', title='Test insight', - ... image_url='url') # doctest: +SKIP - """ - request = self.__build_insight_obj( - lambda: _swagger.InsightCreateRequest( - title=kwargs.get('title'), - body=_swagger.InsightBody( - image_url=kwargs.get('image_url'), - embed_url=kwargs.get('embed_url'), - markdown_body=kwargs.get('markdown_body') - ) - ), kwargs) - project_owner, project_id = parse_dataset_key(project_key) - try: - (_, _, headers) = self._insights_api.create_insight_with_http_info( - project_owner, - project_id, - body=request, - _return_http_data_only=False) - if 'Location' in headers: - return headers['Location'] - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def replace_insight(self, project_key, insight_id, **kwargs): - """Replace an insight. - - :param project_key: Projrct identifier, in the form of - projectOwner/projectid - :type project_key: str - :param insight_id: Insight unique identifier. - :type insight_id: str - :param title: Insight title - :type title: str - :param description: Insight description. - :type description: str, optional - :param image_url: If image-based, the URL of the image - :type image_url: str - :param embed_url: If embed-based, the embeddable URL - :type embed_url: str - :param source_link: Permalink to source code or platform this insight - was generated with. Allows others to replicate the steps originally - used to produce the insight. - :type source_link: str, optional - :param data_source_links: One or more permalinks to the data sources - used to generate this insight. Allows others to access the data - originally used to produce the insight. - :type data_source_links: array - :returns: message object - :rtype: object - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.replace_insight( - ... 'projectOwner/projectid', - ... '1230-9324-3424242442', - ... embed_url='url', - ... title='Test insight') # doctest: +SKIP - """ - request = self.__build_insight_obj( - lambda: _swagger.InsightPutRequest( - title=kwargs.get('title'), - body=_swagger.InsightBody( - image_url=kwargs.get('image_url'), - embed_url=kwargs.get('embed_url'), - markdown_body=kwargs.get('markdown_body') - ) - ), kwargs) - project_owner, project_id = parse_dataset_key(project_key) - try: - self._insights_api.replace_insight(project_owner, - project_id, - insight_id, - body=request) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def update_insight(self, project_key, insight_id, **kwargs): - """Update an insight. - - **Note that only elements included in the request will be updated. All - omitted elements will remain untouched. - :param project_key: Projrct identifier, in the form of - projectOwner/projectid - :type project_key: str - :param insight_id: Insight unique identifier. - :type insight_id: str - :param title: Insight title - :type title: str - :param description: Insight description. - :type description: str, optional - :param image_url: If image-based, the URL of the image - :type image_url: str - :param embed_url: If embed-based, the embeddable URL - :type embed_url: str - :param source_link: Permalink to source code or platform this insight - was generated with. Allows others to replicate the steps originally - used to produce the insight. - :type source_link: str, optional - :param data_source_links: One or more permalinks to the data sources - used to generate this insight. Allows others to access the data - originally used to produce the insight. - :type data_source_links: array - :returns: message object - :rtype: object - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> api_client.update_insight( - ... 'username/test-project', 'insightid' - ... title='demo atadotworld'}) # doctest: +SKIP - """ - request = self.__build_insight_obj( - lambda: _swagger.InsightPatchRequest(), kwargs) - project_owner, project_id = parse_dataset_key(project_key) - try: - self._insights_api.update_insight(project_owner, - project_id, - insight_id, body=request) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - def delete_insight(self, project_key, insight_id): - """Delete an existing insight. - - :params project_key: Project identifier, in the form of - projectOwner/projectId - :type project_key: str - :params insight_id: Insight unique id - :type insight_id: str - :raises RestApiException: If a server error occurs - - Examples - -------- - >>> import datadotworld as dw - >>> api_client = dw.api_client() - >>> del_insight = api_client.delete_insight( - ... 'username/project', 'insightid') # doctest: +SKIP - """ - projectOwner, projectId = parse_dataset_key(project_key) - try: - self._insights_api.delete_insight(projectOwner, - projectId, - insight_id) - except _swagger.rest.ApiException as e: - raise RestApiError(cause=e) - - @staticmethod - def __build_dataset_obj(dataset_constructor, file_constructor, args): - files = ([file_constructor( - name, - url=file_info.get('url'), - expand_archive=file_info.get('expand_archive', False), - description=file_info.get('description'), - labels=file_info.get('labels')) - for name, file_info in args['files'].items()] - if 'files' in args else None) - dataset = dataset_constructor() - if 'title' in args: - dataset.title = args['title'] - if 'description' in args: - dataset.description = args['description'] - if 'summary' in args: - dataset.summary = args['summary'] - if 'tags' in args: - dataset.tags = args['tags'] - if 'license' in args: - dataset.license = args.get('license') - if 'visibility' in args: - dataset.visibility = args['visibility'] - - dataset.files = files - - return dataset - - @staticmethod - def __build_project_obj(project_constructor, file_constructor, args): - - files = ([file_constructor( - name, - url=file_info.get('url'), - description=file_info.get('description'), - labels=file_info.get('labels')) - for name, file_info in args['files'].items()] - if 'files' in args else None) - project = project_constructor() - if 'title' in args: - project.title = args['title'] - if 'summary' in args: - project.summary = args['summary'] - if 'tags' in args: - project.tags = args['tags'] - if 'license' in args: - project.license = args['license'] - if 'visibility' in args: - project.visibility = args['visibility'] - if 'objective' in args: - project.objective = args['objective'] - if 'linked_datasets' in args: - project.linked_datasets = args['linked_datasets'] - - project.files = files - return project - - @staticmethod - def __build_insight_obj(insight_constructor, args): - insight = insight_constructor() - if 'title' in args: - insight.title = args['title'] - if ('image_url' in args or - 'embed_url' in args or - 'markdown_body' in args): - insight.body = _swagger.InsightBody( - image_url=args.get('image_url'), - embed_url=args.get('embed_url'), - markdown_body=args.get('markdown_body') - ) - if 'description' in args: - insight.description = args['description'] - if 'source_link' in args: - insight.source_link = args['source_link'] - if 'data_source_links' in args: - insight.data_source_links = args['data_source_links'] - return insight + self.ApiClient = ApiClient(self._config.auth_token) class RestApiError(Exception): @@ -1417,11 +47,7 @@ def __init__(self, *args, **kwargs): self.cause = kwargs.pop('cause', None) self.status, self.reason, self.body = None, None, None if self.cause is not None: - if type(self.cause) is _swagger.rest.ApiException: - self.status = self.cause.status - self.reason = self.cause.reason - self.body = self.cause.body - elif type(self.cause) is requests.RequestException: + if type(self.cause) is requests.RequestException: requests_response = self.cause.response if requests_response is not None: self.status = requests_response.status_code @@ -1436,10 +62,8 @@ def __init__(self, *args, **kwargs): def json(self): """Attempts to parse json in the body of response to failed requests - Data.world often includes a JSON body for errors; however, there are no guarantees. - :returns: The JSON body if one is included. Otherwise, None. :rtype: dict (json) """ diff --git a/datadotworld/client/api_client.py b/datadotworld/client/api_client.py new file mode 100644 index 0000000..296f53c --- /dev/null +++ b/datadotworld/client/api_client.py @@ -0,0 +1,75 @@ +# coding: utf-8 +""" + data.world API + + data.world is designed for data and the people who work with data. + From professional projects to open data, data.world helps you host + and share your data, collaborate with your team, and capture context + and conclusions as you work. Using this API users are able to easily + access data and manage their data projects regardless of language or + tool of preference. Check out our + [documentation] (https://dwapi.apidocs.io) + for tips on how to get started, tutorials and to interact with the API + right within your browser. + + OpenAPI spec version: 0.14.1 + Contact: help@data.world + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + +from __future__ import absolute_import +from time import sleep +import backoff +import requests +from requests.adapters import HTTPAdapter, BaseAdapter +from .projects_api import ProjectsApi + +MAX_TRIES = 10 + + +class ApiClient(object): + def __init__(self, api_token, **kwargs): + """Simple client for data.world API + :param api_token: API Authorization Token + :type api_token: str + """ + + # The following properties can be overwritten for testing/tuning + self._api_url = kwargs.get('api_url', 'https://api.data.world/v0/') + + default_headers = { + 'Accept': 'application/json', + 'Authorization': 'Bearer {}'.format(api_token), + 'Content-Type': 'application/json', + 'User-Agent': 'data.world-py/2.0' + } + self._session = requests.Session() + self._session.headers.update(default_headers) + + self._session.mount(self._api_url, BackoffAdapter(HTTPAdapter())) + + self.projects = ProjectsApi(self._api_url, self._session) + + +class BackoffAdapter(BaseAdapter): + def __init__(self, delegate): + """Requests adapter for retrying throttled requests (HTTP 429) + :param delegate: Adapter to delegate final request processing to + :type delegate: requests.adapters.BaseAdapter + """ + self._delegate = delegate + super(BackoffAdapter, self).__init__() + + @backoff.on_predicate(backoff.expo, + predicate=lambda r: r.status_code == 429, + max_tries=lambda: MAX_TRIES) + def send(self, request, **kwargs): + resp = self._delegate.send(request, **kwargs) + if (resp.status_code == 429 and + resp.headers.get('Retry-After')): + sleep(int(resp.headers.get('Retry-After'))) + + return resp + + def close(self): + self._delegate.close() diff --git a/datadotworld/client/content_negotiating_api_client.py b/datadotworld/client/content_negotiating_api_client.py index ac8d890..1d0b119 100644 --- a/datadotworld/client/content_negotiating_api_client.py +++ b/datadotworld/client/content_negotiating_api_client.py @@ -1,4 +1,4 @@ -from ._swagger.api_client import ApiClient +from .api_client import ApiClient class ContentNegotiatingApiClient(ApiClient): @@ -10,7 +10,7 @@ def __init__(self, host, header_name, header_value, user_agent, self.user_agent = user_agent self.default_mimetype_header_accept = default_mimetype_header_accept - def select_header_accept(self, accepts): + def select_header_accept(self, accepts): if not accepts: return accepts = [x.lower() for x in accepts] diff --git a/datadotworld/client/modules/__init__.py b/datadotworld/client/modules/__init__.py new file mode 100644 index 0000000..726a8c7 --- /dev/null +++ b/datadotworld/client/modules/__init__.py @@ -0,0 +1,2 @@ +from .api_client import ApiClient + diff --git a/datadotworld/client/modules/api_client.py b/datadotworld/client/modules/api_client.py new file mode 100644 index 0000000..c76427a --- /dev/null +++ b/datadotworld/client/modules/api_client.py @@ -0,0 +1,278 @@ +# coding: utf-8 +""" + data.world API + + data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. + + OpenAPI spec version: 0.14.1 + Contact: help@data.world + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + +from __future__ import absolute_import + +import os +import re +import json +import mimetypes +import tempfile +import threading +import backoff + +from datetime import date, datetime +from requests.adapters import BaseAdapter + + +# python 2 and python 3 compatibility library +from six import PY3, integer_types, iteritems, text_type +from six.moves.urllib.parse import quote + +class ApiClient(object): + def __init__(self, api_token, **kwargs): + """Simple client for data.world API + :param api_token: API Authorization Token + :type api_token: str + """ + + # The following properties can be overwritten for testing/tuning + self._api_url = kwargs.get('api_url', 'https://api.data.world/v0') + self._conn_timeout = kwargs.get('connect_timeout', 3.05) + self._read_timeout = kwargs.get('read_timeout', 600) + self._max_threads = kwargs.get('max_threads', 10) + + self.default_headers = { + 'Accept': 'application/json', + 'Authorization': 'Bearer {}'.format(api_token), + 'Content-Type': 'application/json', + 'User-Agent': 'data.world-py' + } + + def connection_check(self): + """Verify network connectivity + Ensures that the client can communicate with data.world's API + """ + with metrics.http_request_timer('user'): + try: + self._session.get( + '{}/user'.format(self._api_url), + timeout=(self._conn_timeout, self._read_timeout) + ).raise_for_status() + except RequestException as e: + raise convert_requests_exception(e) + + def append_stream(self, owner, dataset, stream, records): + """Append records to a stream in a data.world dataset + :param owner: User or organization ID of the owner of the dataset + :type owner: str + :param dataset: Dataset ID + :type dataset: str + :param stream: Stream ID + :type stream: str + :param records: Objects to be appended to the stream + :type records: iterable + :raises ApiError: Failure invoking data.world API + """ + with metrics.http_request_timer('append') as t: + t.tags['stream'] = stream + + try: + self._session.post( + '{}/streams/{}/{}/{}'.format( + self._api_url, owner, dataset, stream), + data=to_jsonlines(records).encode('utf-8'), + headers={'Content-Type': + 'application/json-l; charset=utf-8'} + ).raise_for_status() + except RequestException as e: + raise convert_requests_exception(e) + + """Asynchronously append records to a stream in a data.world dataset + :param owner: User or organization ID of the owner of the dataset + :type owner: str + :param dataset: Dataset ID + :type dataset: str + :param stream: Stream ID + :type stream: str + :param queue: Queue with objects to be appended to the stream + :type queue: asyncio.Queue + :param chunk_size: Chunk or batch size + :type chunk_size: int + :raises ApiError: Failure invoking data.world API + """ + + def create_dataset(self, owner, dataset, **kwargs): + """Create a new dataset + :param owner: User or organization ID of the owner of the dataset + :type owner: str + :param dataset: Dataset ID + :type dataset: str + :param kwargs: Dataset properties + :type kwargs: dict + :returns: Response object + :rtype: object + :raises ApiError: Failure invoking data.world API + .. seealso:: `Dataset properties + `_ + """ + with metrics.http_request_timer('create_dataset'): + try: + resp = self._session.put( + '{}/datasets/{}/{}'.format(self._api_url, owner, dataset), + json=kwargs, + timeout=(self._conn_timeout, self._read_timeout) + ) + resp.raise_for_status() + return resp.json() + except RequestException as e: + raise convert_requests_exception(e) + + def get_dataset(self, owner, dataset): + """Fetch dataset info + :param owner: User or organization ID of the owner of the dataset + :type owner: str + :param dataset: Dataset ID + :type dataset: str + :returns: Dataset object + :rtype: object + :raises ApiError: Failure invoking data.world API + """ + with metrics.http_request_timer('dataset'): + try: + resp = self._session.get( + '{}/datasets/{}/{}'.format(self._api_url, owner, dataset), + timeout=(self._conn_timeout, self._read_timeout) + ) + resp.raise_for_status() + return resp.json() + except RequestException as e: + raise convert_requests_exception(e) + + def get_current_version(self, owner, dataset, stream): + """Returns version of a sample record from a given stream + :param owner: User or organization ID of the owner of the dataset + :type owner: str + :param dataset: Dataset ID + :type dataset: str + :param stream: Stream ID + :type stream: str + :returns: Response object + :rtype: object + :raises ApiError: Failure invoking data.world API + """ + with metrics.http_request_timer('fetch_latest_version'): + try: + resp = self._session.get( + '{}/sql/{}/{}'.format(self._api_url, owner, dataset), + params={ + 'query': 'SELECT * ' + 'FROM `{}`.`{}`.`{}` ' + 'LIMIT 1'.format( + owner, dataset, to_table_name(stream))}, + timeout=(self._conn_timeout, self._read_timeout)) + resp.raise_for_status() + rows = resp.json() + return (None if len(rows) == 0 + else rows[0].get('singer_version')) + except RequestException as e: + if e.response.status_code == 400: + logger.warn('Unable fetch latest version. ' + 'Expected if table doesn\'t exist yet. ' + 'Server message: {}'.format(e.response.text)) + return None + raise convert_requests_exception(e) + + def set_stream_schema(self, owner, dataset, stream, **kwargs): + """Sets schema of a stream in a data.world dataset + :param owner: User or organization ID of the owner of the dataset + :type owner: str + :param dataset: Dataset ID + :type dataset: str + :param stream: Stream ID + :type stream: str + :param kwargs: Schema properties (primaryKeyFields, sequenceField, + updateMethod) + :type kwargs: dict + :returns: Response object + :rtype: object + :raises ApiError: Failure invoking data.world API + """ + with metrics.http_request_timer('set_stream_schema'): + try: + resp = self._session.patch( + '{}/streams/{}/{}/{}/schema'.format(self._api_url, owner, + dataset, stream), + json=kwargs, + timeout=(self._conn_timeout, self._read_timeout) + ) + resp.raise_for_status() + return resp.json() + except RequestException as e: + raise convert_requests_exception(e) + + def sync(self, owner, dataset): + """Triggers ingest of streamed records + :param owner: User or organization ID of the owner of the dataset + :type owner: str + :param dataset: Dataset ID + :type dataset: str + :returns: Response object + :rtype: object + :raises ApiError: Failure invoking data.world API + """ + with metrics.http_request_timer('sync'): + try: + resp = self._session.post( + '{}/datasets/{}/{}/sync'.format( + self._api_url, owner, dataset), + timeout=(self._conn_timeout, self._read_timeout)) + resp.raise_for_status() + return resp.json() + except RequestException as e: + raise convert_requests_exception(e) + + def truncate_stream_records(self, owner, dataset, stream): + """Truncates records of a stream in a data.world dataset + :param owner: User or organization ID of the owner of the dataset + :type owner: str + :param dataset: Dataset ID + :type dataset: str + :param stream: Stream ID + :type stream: str + :returns: Response object + :rtype: object + :raises ApiError: Failure invoking data.world API + """ + with metrics.http_request_timer('truncate_stream_records'): + try: + resp = self._session.delete( + '{}/streams/{}/{}/{}/records'.format(self._api_url, owner, + dataset, stream), + timeout=(self._conn_timeout, self._read_timeout) + ) + resp.raise_for_status() + return resp.json() + except RequestException as e: + raise convert_requests_exception(e) + +class BackoffAdapter(BaseAdapter): + def __init__(self, delegate): + """Requests adapter for retrying throttled requests (HTTP 429) + :param delegate: Adapter to delegate final request processing to + :type delegate: requests.adapters.BaseAdapter + """ + self._delegate = delegate + super(BackoffAdapter, self).__init__() + + @backoff.on_predicate(backoff.expo, + predicate=lambda r: r.status_code == 429, + max_tries=lambda: MAX_TRIES) + def send(self, request, **kwargs): + resp = self._delegate.send(request, **kwargs) + if (resp.status_code == 429 and + resp.headers.get('Retry-After')): + sleep(int(resp.headers.get('Retry-After'))) + + return resp + + def close(self): + self._delegate.close() diff --git a/datadotworld/client/projects_api.py b/datadotworld/client/projects_api.py new file mode 100644 index 0000000..b959cb6 --- /dev/null +++ b/datadotworld/client/projects_api.py @@ -0,0 +1,128 @@ +from uplink import Consumer, get, post, patch, put, delete, Body,\ + json, args, Path + + +class ProjectsApi(Consumer): + @get("projects/{owner_id}/{project_id}") + def get_project(self, owner_id, project_id): + """Retrieve a project. + The definition of the project will be returned, + not the associated data. + :param owner_id: User or organization ID of the owner of the dataset + :type owner_id: str + :param project_id: Unique identifier of dataset + """ + pass + + @args(Path, Body) + @json + @post("projects/{owner_id}") + def create_project(self, owner_id, **kwargs): + """Create a new project. + :param owner_id: User or organization ID of the owner of the dataset + :type owner_id: str + :kwargs is Body of + [https://apidocs.data.world/api/projects/createproject] + """ + pass + + @args(Path, Path, Body) + @json + @patch("projects/{owner_id}/{project_id}") + def patch_project(self, owner_id, project_id, **kwargs): + """Update an existing project. + Only elements included in the request will be updated. + All omitted elements will remain untouched. + :param owner_id: User or organization ID of the owner of the dataset + :type owner_id: str + :param project_id: Unique identifier of dataset + :type dataset: str + :kwargs is Body of + [https://apidocs.data.world/api/projects/patchproject] + """ + pass + + @args(Path, Path, Body) + @json + @put("projects/{owner_id}/{project_id}") + def replace_project(self, owner_id, project_id, **kwargs): + """Create or replace a project with a given id. + If a project exists with the same id, this call will reset + such project redefining all its attributes. + :param owner_id: User or organization ID of the owner of the dataset + :type owner_id: str + :param project_id: Unique identifier of dataset + :type dataset: str + :kwargs is Body of + [https://apidocs.data.world/api/projects/replaceproject] + """ + pass + + @args(Path, Path) + @delete("projects/{owner_id}/{project_id}") + def delete_project(self, owner_id, project_id): + """Delete a project and associated data. + This operation cannot be undone, but you may recreate the project + using the same id. + :User must have admin auth token + :param owner_id: User or organization ID of the owner of the dataset + :type owner_id: str + :param project_id: Unique identifier of dataset + :type dataset: str + """ + pass + + @args(Path, Path, Path, Path, Body) + @json + @put("projects/{owner_id}/{project_id}/linkedDatasets/" + + "{linked_dataset_owner}/{linked_dataset_id}") + def add_linked_dataset(self, owner_id, project_id, linked_dataset_owner, + linked_dataset_id, **kwargs): + """ + https://apidocs.data.world/api/projects/addlinkeddataset + Add Link dataset + :param callback function: The callback function + for asynchronous request. (optional) + :param str owner: User name and unique identifier of the creator. + :param str id: Project unique identifier. + :param str linked_dataset_owner: (required) + :param str linked_dataset_id: (required) + :return: SuccessMessage + If the method is called asynchronously, + returns the request thread. + """ + pass + + @args(Path, Path, Path, Path, Body) + @json + @delete("projects/{owner_id}/{project_id}/linkedDatasets/" + + "{linked_dataset_owner}/{linked_dataset_id}") + def remove_linked_dataset(self, owner_id, project_id, + linked_dataset_owner, linked_dataset_id, + **kwargs): + """ + https://apidocs.data.world/api/projects/removelinkeddataset + Remove Link dataset + :param callback function: The callback function + for asynchronous request. (optional) + :param str owner: User name and unique identifier of the creator. + :param str id: Project unique identifier. + :param str linked_dataset_owner: (required) + :param str linked_dataset_id: (required) + :return: SuccessMessage + If the method is called asynchronously, + returns the request thread. + """ + pass + + # + # def execute_sql(self, owner_id, dataset_id, **kwargs): + # preparedRequest = // set request up + # return QueryRequest(preparedRequest) + # + # class QueryRequest(object): + # def to_csv(self): + # preparedRequest.headers['Accept'] = 'text/csv' + # return preparedRequest.send() + # + # def to_json(self): diff --git a/datadotworld/client/swagger-codegen-config.json b/datadotworld/client/swagger-codegen-config.json deleted file mode 100644 index 75b91dc..0000000 --- a/datadotworld/client/swagger-codegen-config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "packageName": "_swagger" -} diff --git a/datadotworld/client/swagger-dwapi-def.json b/datadotworld/client/swagger-dwapi-def.json deleted file mode 100644 index 0d718b5..0000000 --- a/datadotworld/client/swagger-dwapi-def.json +++ /dev/null @@ -1,4452 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "0.14.1", - "title": "data.world API", - "termsOfService": "https://data.world/terms", - "contact": { - "name": "data.world", - "url": "https://data.world", - "email": "help@data.world" - }, - "license": { - "name": "Apache 2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0" - }, - "description": "data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. \nUsing this API users are able to easily access data and manage their data projects regardless of language or tool of preference. \nCheck out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser.", - "x-stoplight": { - "id": "data-world/specs/data-world" - } - }, - "host": "api.data.world", - "basePath": "/v0", - "tags": [ - { - "name": "datasets" - }, - { - "name": "download" - }, - { - "name": "uploads" - }, - { - "name": "sparql" - }, - { - "name": "sql" - }, - { - "name": "user" - }, - { - "name": "streams" - }, - { - "name": "projects" - } - ], - "schemes": [ - "https" - ], - "paths": { - "/streams/{owner}/{id}/{streamId}": { - "post": { - "tags": [ - "streams" - ], - "summary": "Append records to a stream.", - "operationId": "appendRecords", - "consumes": [ - "application/json-l", - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "$ref": "#/parameters/streamId" - }, - { - "in": "body", - "name": "body", - "required": true, - "schema": { - "type": "object", - "properties": {} - }, - "x-examples": { - "application/json": "{\r\n \"someProperty\": \"someValue\",\r\n \"aNumericProperty\": 42,\r\n \"aBooleanProperty\": false\r\n}" - } - } - ], - "responses": { - "202": { - "description": "Record(s) accepted." - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "This endpoint appends JSON data to a stream associated with a dataset. Streams don't need to be created before you can append data to it. They will be created on-demand, the first time they are used.\n\nMultiple records can be appended at once by using JSON-L (`application/json-l`) as the request content type.\n\nCurrently, data uploaded to a dataset via a stream is not immediatelly processed. Instead, it is processed automatically at least once a day or as a result of a \"Sync files\" endpoint invocation.\n\nOnce processed, the contents of a stream will appear as part of the respective dataset as a `.jsonl` file (e.g. `my-stream` will produce a file named `my-stream.jsonl`)." - } - }, - "/download/{owner}/{id}": { - "get": { - "tags": [ - "download" - ], - "summary": "Download dataset", - "description": "This endpoint will return a .zip containing all files within the dataset as originally uploaded. \nIf you are interested retrieving clean data extracted from those files by data.world, check out `GET:/sql` and `GET:/sparql`.", - "operationId": "downloadDataset", - "produces": [ - "application/zip" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - } - ], - "responses": { - "200": { - "description": "__OK__\nThe request has succeeded." - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ] - } - }, - "/file_download/{owner}/{id}/{file}": { - "get": { - "tags": [ - "download" - ], - "summary": "Download file", - "description": "This endpoint will return a file within the dataset as originally uploaded. \nIf you are interested retrieving clean data extracted from those files by data.world, check out `GET:/sql` and `GET:/sparql`.", - "operationId": "downloadFile", - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "$ref": "#/parameters/file" - } - ], - "responses": { - "200": { - "description": "__OK__\nThe request has succeeded." - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ] - } - }, - "/sparql/{owner}/{id}": { - "get": { - "tags": [ - "sparql" - ], - "summary": "SPARQL query (via GET)", - "description": "This endpoint executes SPARQL queries against a dataset or data project.\n\nSPARQL results are available in a variety of formats. By default, `application/sparql-results+json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference:\n\n- `application/sparql-results+xml`\n- `application/sparql-results+json`\n- `application/rdf+json`\n- `application/rdf+xml`\n- `text/csv`\n- `text/tab-separated-values`\n\nNew to SPARQL? Check out data.world’s[SPARQL tutorial](https://docs.data.world/tutorials/sparql/).", - "operationId": "sparqlGet", - "produces": [ - "application/sparql-results+json", - "application/sparql-results+xml", - "application/rdf+json", - "application/rdf+xml", - "text/tab-separated-values", - "text/csv" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "$ref": "#/parameters/query" - } - ], - "responses": { - "200": { - "description": "__OK__\nThe request has succeeded." - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ] - }, - "post": { - "tags": [ - "sparql" - ], - "summary": "SPARQL query", - "description": "This endpoint executes SPARQL queries against a dataset or data project. \n\nSPARQL results are available in a variety of formats. By default, `application/sparql-results+json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference:\n\n- `application/sparql-results+xml`\n- `application/sparql-results+json`\n- `application/rdf+json`\n- `application/rdf+xml`\n- `text/csv`\n- `text/tab-separated-values`\n\nNew to SPARQL? Check out data.world's [SPARQL tutorial](https://docs.data.world/tutorials/sparql/).", - "operationId": "sparqlPost", - "produces": [ - "application/sparql-results+json", - "application/sparql-results+xml", - "application/rdf+json", - "application/rdf+xml", - "text/tab-separated-values", - "text/csv" - ], - "consumes": [ - "application/x-www-form-urlencoded" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "$ref": "#/parameters/formQuery" - } - ], - "responses": { - "200": { - "description": "__OK__\nThe request has succeeded.", - "examples": { - "application/x-www-form-urlencoded": "{}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ] - } - }, - "/sql/{owner}/{id}": { - "get": { - "tags": [ - "sql" - ], - "summary": "SQL query (via GET)", - "description": "This endpoint executes SQL queries against a dataset.\n\nSQL results are available in a variety of formats. By default, `application/json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference:\n\n* `text/csv`\n* `application/json`\n* `application/json-l`\n* `application/x-ndjson`\n\nNew to SQL? Check out data.world's [SQL manual](https://docs.data.world/tutorials/dwsql/) .", - "operationId": "sqlGet", - "produces": [ - "application/json", - "application/json-l", - "application/x-ndjson", - "text/csv" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "$ref": "#/parameters/query" - }, - { - "$ref": "#/parameters/includeTableSchema" - } - ], - "responses": { - "200": { - "description": "__OK__\nThe request has succeeded." - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ] - }, - "post": { - "tags": [ - "sql" - ], - "summary": "SQL query", - "description": "This endpoint executes SQL queries against a dataset.\n\nSQL results are available in a variety of formats. By default, `application/json` will be returned. Set the `Accept` header to one of the following values in accordance with your preference:\n\n* `text/csv`\n* `application/json`\n* `application/json-l`\n* `application/x-ndjson`\n\nNew to SQL? Check out data.world's [SQL manual](https://docs.data.world/tutorials/dwsql/) .", - "operationId": "sqlPost", - "consumes": [ - "application/x-www-form-urlencoded" - ], - "produces": [ - "application/json", - "application/json-l", - "application/x-ndjson", - "text/csv" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "$ref": "#/parameters/formQuery" - }, - { - "$ref": "#/parameters/includeTableSchema" - } - ], - "responses": { - "200": { - "description": "__OK__\nThe request has succeeded." - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ] - } - }, - "/datasets/{owner}": { - "post": { - "tags": [ - "datasets" - ], - "summary": "Create a dataset", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "in": "body", - "name": "body", - "required": true, - "schema": { - "$ref": "#/definitions/DatasetCreateRequest" - }, - "x-examples": { - "application/json": "{\r\n \"title\": \"data.world basketball team\",\r\n \"description\": \"Fake data.world basketball team players and stats\",\r\n \"summary\": \"This dataset involves some fake information about the totally fake data.world intramural basketball team.\",\r\n \"tags\": [\r\n \"sports\", \"datadotworld\", \"basketball\"\r\n ],\r\n \"license\": \"PDDL\",\r\n \"visibility\": \"OPEN\",\r\n \"files\": [\r\n {\r\n \"name\": \"DataDotWorldBBallTeam.csv\",\r\n \"source\": {\r\n \"url\": \"https://docs.google.com/spreadsheets/d/1UheyB6pxTCfLpRmIGITM0fKb8jHVEvPuajmuejxxRyE/pub?gid=1371600687&single=true&output=csv\"\r\n },\r\n \"description\": \"Stats about about our purely fictitious basketball team\",\r\n \"labels\": [\r\n \"raw data\", \"clean data\"\r\n ]\r\n }\r\n ]\r\n}" - } - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/CreateDatasetResponse" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "409": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**CONFLICT**\nThe request could not be completed due to a conflict with the current state of the resource.\nFor example, this may occur for a short period of time after deleting a dataset with the same datasetId as the dataset being created." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "consumes": [ - "application/json" - ], - "description": "Create a new dataset.", - "operationId": "createDataset" - } - }, - "/datasets/{owner}/{id}": { - "delete": { - "tags": [ - "datasets" - ], - "operationId": "deleteDataset", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - }, - "examples": { - "application/json": "{\n \"message\": \"Dataset has been successfully deleted.\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "Permanently deletes a dataset and all data associated with it. This operation cannot be undone, although a new dataset may be created with the same id.", - "summary": "Delete a dataset" - }, - "get": { - "tags": [ - "datasets" - ], - "summary": "Retrieve a dataset", - "operationId": "getDataset", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/DatasetSummaryResponse" - }, - "examples": { - "application/json": { - "owner": "sya", - "id": "trumpworld", - "title": "TrumpWorld", - "description": "TrumpWorld Data", - "summary": "From the Buzzfeed article [Help Us Map TrumpWorld](https://www.buzzfeed.com/johntemplon/help-us-map-trumpworld)\n>No American president has taken office with a giant network of businesses, investments, and corporate connections like that amassed by Donald J. Trump. His family and advisers have touched a staggering number of ventures, from a hotel in Azerbaijan to a poker company in Las Vegas.\n\n\nCheck out the data.world docs on how to Upload & sync files from [**Google Sheets**](https://docs.data.world/documentation/api/googleSync.html) and [**Github**](https://docs.data.world/documentation/api/githubSync.html) \n\n\nSource: [github.com/BuzzFeedNews](https://github.com/BuzzFeedNews/trumpworld/tree/master/data) \n\n_If you have suggestions for expanding or improving the dataset, please email trump@buzzfeed.com. If you’d like to send your tip securely and anonymously, see these [instructions](https://tips.buzzfeed.com/)._", - "tags": [ - "trump", - "trump world", - "president", - "connections", - "swamp", - "business network" - ], - "visibility": "OPEN", - "files": [ - { - "name": "org-org-connections.csv", - "sizeInBytes": 97658, - "source": { - "id": "bfbac3bb-9cec-410a-9ac4-c904a56d65fe", - "url": "https://raw.githubusercontent.com/BuzzFeedNews/trumpworld/master/data/org-org-connections.csv", - "syncStatus": "OK", - "lastSyncStart": "2017-02-06T22:55:15.242Z", - "lastSyncSuccess": "2017-02-06T22:55:15.258Z", - "lastSyncFailure": "2017-02-01T23:47:47.667Z" - }, - "created": "2017-02-01T23:45:12.379Z", - "updated": "2017-02-03T16:05:03.241Z" - }, - { - "name": "person-org-connections.csv", - "sizeInBytes": 231637, - "source": { - "id": "91cf66e3-4bd7-422f-a8ec-7de1b68f8ee1", - "url": "https://raw.githubusercontent.com/BuzzFeedNews/trumpworld/master/data/person-org-connections.csv", - "syncStatus": "OK", - "lastSyncStart": "2017-02-06T22:55:15.242Z", - "lastSyncSuccess": "2017-02-06T22:55:15.310Z" - }, - "created": "2017-02-01T23:51:02.777Z", - "updated": "2017-02-03T16:05:03.241Z" - }, - { - "name": "person-person-connections.csv", - "sizeInBytes": 32556, - "source": { - "id": "b1e0659b-c282-408a-893a-14b5e5a1ae4c", - "url": "https://raw.githubusercontent.com/BuzzFeedNews/trumpworld/master/data/person-person-connections.csv", - "syncStatus": "OK", - "lastSyncStart": "2017-02-06T22:55:15.242Z", - "lastSyncSuccess": "2017-02-06T22:55:15.361Z" - }, - "created": "2017-02-01T23:51:32.492Z", - "updated": "2017-02-03T16:05:03.241Z" - } - ], - "status": "LOADED", - "created": "2017-02-01T22:33:58.809Z", - "updated": "2017-02-06T22:55:19.128Z", - "isProject": false, - "accessLevel": "READ" - } - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "Return details on the dataset." - }, - "put": { - "tags": [ - "datasets" - ], - "operationId": "replaceDataset", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "in": "body", - "name": "body", - "required": true, - "schema": { - "$ref": "#/definitions/DatasetPutRequest" - }, - "x-examples": { - "application/json": "{\n \"description\": \"2017 data.world basketball program\",\n \"summary\": \"Fake data.world basketball team players and stats. Includes 2016 and 2017 team\",\n \"tags\": [\n \"basketball\"\n ],\n \"visibility\": \"OPEN\",\n \"files\": [\n {\n \"name\": \"DataDotWorld2017BBallTeam.csv\",\n \"source\": {\n \"url\": \"https://docs.google.com/spreadsheets/d/1UheyB6pxTCfLpRmIGITM0fKb8jHVEvPuajmuejxxRyE/pub?gid=1371600687&single=true&output=csv\"\n },\n \"description\": \"Purely fictitious performance data on our purely fictitious data.world basketball team.\",\n \"labels\": [\n \"raw data\", \"clean data\"\n ]\n }\n ]\n}" - } - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - }, - "examples": { - "application/json": "{\n \"message\": \"Dataset has been successfully replaced.\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "consumes": [ - "application/json" - ], - "description": "Create a dataset with a given id or completely rewrite the dataset, including any previously added files, if one already exists with the given id.", - "summary": "Create / Replace a dataset" - }, - "patch": { - "tags": [ - "datasets" - ], - "summary": "Update a dataset", - "operationId": "patchDataset", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "in": "body", - "name": "body", - "required": true, - "schema": { - "$ref": "#/definitions/DatasetPatchRequest" - }, - "x-examples": { - "application/json": "{\r\n \"description\": \"2017 data.world basketball program\",\r\n \"summary\": \"Fake data.world basketball team players and stats. Includes 2016 and 2017 team\",\r\n \"tags\": [\r\n \"basketball\"\r\n ],\r\n \"files\": [\r\n {\r\n \"name\": \"DataDotWorld2017BBallTeam.csv\",\r\n \"source\": {\r\n \"url\": \"https://docs.google.com/spreadsheets/d/1UheyB6pxTCfLpRmIGITM0fKb8jHVEvPuajmuejxxRyE/pub?gid=1371600687&single=true&output=csv\"\r\n },\r\n \"description\": \"Purely fictitious performance data on our purely fictitious data.world basketball team.\",\r\n \"labels\": [\r\n \"raw data\", \"clean data\"\r\n ]\r\n }\r\n ]\r\n}" - } - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - }, - "examples": { - "application/json": "{\n \"message\": \"Dataset successfully updated.\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "Update an existing dataset. Note that only elements or files included in the request will be updated. All omitted elements or files will remain untouched.", - "consumes": [ - "application/json" - ] - } - }, - "/datasets/{owner}/{id}/files": { - "post": { - "tags": [ - "datasets" - ], - "summary": "Add files", - "operationId": "addFilesBySource", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "in": "body", - "name": "body", - "required": true, - "schema": { - "$ref": "#/definitions/FileBatchUpdateRequest" - }, - "x-examples": { - "application/json": "{\n \"files\": [\n {\n \"name\": \"DataDotWorldBBallTeam.csv\",\n \"source\": {\n \"url\": \"https://docs.google.com/spreadsheets/d/1UheyB6pxTCfLpRmIGITM0fKb8jHVEvPuajmuejxxRyE/pub?gid=1371600687&single=true&output=csv\"\n },\n \"description\": \"Purely fictitious performance data on our purely fictitious data.world basketball team.\",\n \"labels\": [\n \"raw data\",\n \"clean data\"\n ]\n },\n {\n \"name\": \"DataDotWorldBBallStats.csv\",\n \"source\": {\n \"url\": \"https://raw.githubusercontent.com/rebeccaclay/test-repo/master/DataDotWorldBBallStats.csv\"\n },\n \"description\": \"Stats about about our purely fictitious basketball team\",\n \"labels\": [\n \"raw data\",\n \"clean data\"\n ]\n }\n ]\n}" - } - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - }, - "examples": { - "application/json": "{\n \"message\": \"Dataset has been successfully updated with new sources. Sync in progress.\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "This method allows files published on the web to be added to a data.world dataset via their URL. The source URL will be stored so you can easily update your file anytime it changes via the *fetch latest* link on the [data.world](https://data.world/) dataset page or by triggering the GET:/sync endpoint. \nCheck-out or tutorials for tips on how to add Google Sheets, GitHub and S3 files via URL and how to use webhooks or scripts to keep them always in sync." - }, - "delete": { - "tags": [ - "datasets" - ], - "summary": "Delete files", - "operationId": "deleteFilesAndSyncSources", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "name": "name", - "in": "query", - "required": true, - "type": "array", - "items": { - "type": "string" - }, - "collectionFormat": "multi", - "description": "Names of files to be deleted. Multiple can be provided in a single request by repeating the query string parameter name as many times as necessary.", - "uniqueItems": true - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - }, - "examples": { - "application/json": "{\n \"message\": \"Dataset files have been successfully deleted.\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "Delete one or more files from a dataset by their name, including files added via URL. \n\n**Batching** \nNote that the `name` parameter can be include multiple times in the query string, once for each file that is to be deleted together in a single request." - } - }, - "/datasets/{owner}/{id}/files/{name}": { - "delete": { - "tags": [ - "datasets" - ], - "summary": "Delete a file", - "operationId": "deleteFileAndSyncSource", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "name": "name", - "in": "path", - "description": "Name and unique idenfiier of file within the dataset.", - "required": true, - "type": "string", - "maxItems": 128, - "minItems": 1 - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - }, - "examples": { - "application/json": "{\n \"message\": \"Dataset file has been successfully deleted.\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "Delete a single file from a dataset by their name, including files added via URL." - } - }, - "/datasets/{owner}/{id}/sync": { - "get": { - "tags": [ - "datasets" - ], - "summary": "Sync files (via GET)", - "operationId": "syncViaGet", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - }, - "examples": { - "application/json": "{\n \"message\": \"Sync started.\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "Update all files within a dataset that have originally been added via URL (e.g. via /datasets endpoints or on data.world). \nCheck-out or tutorials for tips on how to add Google Sheets, GitHub and S3 files via URL and how to use webhooks or scripts to keep them always in sync." - }, - "post": { - "tags": [ - "datasets" - ], - "summary": "Sync files", - "operationId": "sync", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - }, - "examples": { - "application/json": "{\n \"message\": \"Sync started.\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "Update all files within a dataset that have originally been added via URL (e.g. via /datasets endpoints or on data.world). \nCheck-out or tutorials for tips on how to add Google Sheets, GitHub and S3 files via URL and how to use webhooks or scripts to keep them always in sync." - } - }, - "/uploads/{owner}/{id}/files": { - "post": { - "tags": [ - "uploads" - ], - "summary": "Upload files", - "description": "Upload multiple files at once to a dataset via multipart request.\n\nThis endpoint expects requests of type `multipart/form-data` and you can include one or more parts named `file`, each containing a different file to be uploaded.\n\nFor example, assuming that, you want to upload two local files named `file1.csv` and `file2.csv` to a hypothetical dataset `https://data.world/awesome-user/awesome-dataset`, this is what the cURL command would look like.\n\n```bash\ncurl \\\n -H \"Authorization: Bearer \" \\\n -F \"file=@file1.csv\" \\\n -F \"file=@file2.csv\" \\\n https://api.data.world/v0/uploads/awesome-user/awesome-dataset/files\n```\n\nSwagger clients will limit this method of upload to one file at a time. Other HTTP clients capable of making multipart/form-data requests can be used to upload multiple files in a single request.", - "operationId": "uploadFiles", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "name": "file", - "in": "formData", - "description": "Multipart-encoded file contents", - "required": true, - "type": "file" - }, - { - "in": "query", - "name": "expandArchives", - "type": "boolean", - "default": false, - "description": "Indicates whether compressed files should be expanded upon upload." - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - }, - "examples": { - "application/json": "{\n \"message\": \"File(s) uploaded.\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "413": { - "description": "**PAYLOAD TOO LARGE**\nThe server is refusing to process a request because the request payload is larger than the server is willing or able to process.", - "schema": { - "$ref": "#/definitions/ErrorMessage" - } - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ] - } - }, - "/uploads/{owner}/{id}/files/{name}": { - "put": { - "tags": [ - "uploads" - ], - "summary": "Upload file", - "description": "Upload one file at a time to a dataset.\n\nThis endpoint expects requests of type `application/octet-stream`.\n\nFor example, assuming that you want to upload a local file named `file1.csv` to a hypothetical dataset `https://data.world/awesome-user/awesome-dataset` and choose its name on data.world to be `better-name.csv`, this is what the cURL command would look like.\n\n```bash\ncurl \\\n -H \"Authorization: Bearer \" \\\n -X PUT -H \"Content-Type: application/octet-stream\" \\\n --data-binary @file1.csv \\\n https://api.data.world/v0/uploads/awesome-user/awesome-dataset/files/better-name.csv\n```\n\nThis method of upload is typically not supported by Swagger clients. Other HTTP clients can be used to supply the contents of the file directly in the body of the request.", - "operationId": "uploadFile", - "consumes": [ - "application/octet-stream", - "*/*" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/owner" - }, - { - "$ref": "#/parameters/datasetId" - }, - { - "name": "name", - "in": "path", - "description": "File name and unique identifier within dataset.", - "required": true, - "type": "string", - "maxItems": 128, - "minItems": 1 - }, - { - "in": "query", - "name": "expandArchive", - "type": "boolean", - "default": false, - "description": "Indicates whether a compressed file should be expanded upon upload." - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - }, - "examples": { - "application/json": "{\n \"message\": \"File uploaded.\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "413": { - "description": "**PAYLOAD TOO LARGE**\nThe server is refusing to process a request because the request payload is larger than the server is willing or able to process.", - "schema": { - "$ref": "#/definitions/ErrorMessage" - } - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ] - } - }, - "/user": { - "get": { - "tags": [ - "user" - ], - "summary": "Get user data", - "operationId": "getUserData", - "produces": [ - "application/json" - ], - "parameters": [], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/UserDataResponse" - }, - "examples": { - "application/json": "{\n \"avatarUrl\": \"https://cdn.filepicker.io/api/file/m0Y31H2NRq6byi22ApUs\",\n \"displayName\": \"Rafael Pereira\",\n \"id\": \"rflprr\",\n \"created\": \"2016-06-13T22:38:29.412Z\",\n \"updated\": \"2017-01-31T17:01:49.847Z\"\n}" - } - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "Return profile information for the currently authenticated user." - } - }, - "/user/datasets/contributing": { - "get": { - "tags": [ - "user" - ], - "summary": "List datasets as contributor", - "operationId": "fetchContributingDatasets", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/limit" - }, - { - "$ref": "#/parameters/next" - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/PaginatedDatasetResults" - }, - "examples": { - "application/json": "{\n \"count\": 2,\n \"records\": [\n {\n \"owner\": \"bryonjacob\",\n \"id\": \"f-o-o\",\n \"title\": \"f-o-o\",\n \"description\": \"why do my datasets have to be at least 5 chars in length\",\n \"tags\": [],\n \"license\": \"CC-0\",\n \"visibility\": \"PRIVATE\",\n \"files\": [\n {\n \"name\": \"foo.csv\",\n \"sizeInBytes\": 56,\n \"created\": \"2016-06-09T21:56:06.943Z\",\n \"updated\": \"2016-06-09T21:56:06.943Z\"\n }\n ],\n \"status\": \"LOADED\",\n \"created\": \"2016-06-09T21:55:58.002Z\",\n \"updated\": \"2017-04-19T15:35:30.791Z\"\n },\n {\n \"owner\": \"eric-capps\",\n \"id\": \"zooblesnarb\",\n \"title\": \"zooblesnarb\",\n \"description\": \"test\",\n \"tags\": [\n \"bap\"\n ],\n \"visibility\": \"OPEN\",\n \"files\": [],\n \"created\": \"2016-11-02T21:18:58.696Z\",\n \"updated\": \"2016-11-11T16:56:30.714Z\"\n }\n ],\n \"next\": \"eyJyZXNvdXJjZSI6eyJzIjoiZGF0YXNldDplcmljLWNhcHBzL3pvb2JsZXNuYXJiIn0sInBhcnR5Ijp7InMiOiJhZ2VudDp1c2VyOCJ9fQ==\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "Fetch datasets that the currently authenticated user has access to because he or she is a contributor." - } - }, - "/user/datasets/liked": { - "get": { - "tags": [ - "user" - ], - "summary": "List liked datasets", - "operationId": "fetchLikedDatasets", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/limit" - }, - { - "$ref": "#/parameters/next" - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/PaginatedDatasetResults" - }, - "examples": { - "application/json": "{\n \"count\": 2,\n \"records\": [\n {\n \"owner\": \"bryonjacob\",\n \"id\": \"f-o-o\",\n \"title\": \"f-o-o\",\n \"description\": \"why do my datasets have to be at least 5 chars in length\",\n \"tags\": [],\n \"license\": \"CC-0\",\n \"visibility\": \"PRIVATE\",\n \"files\": [\n {\n \"name\": \"foo.csv\",\n \"sizeInBytes\": 56,\n \"created\": \"2016-06-09T21:56:06.943Z\",\n \"updated\": \"2016-06-09T21:56:06.943Z\"\n }\n ],\n \"status\": \"LOADED\",\n \"created\": \"2016-06-09T21:55:58.002Z\",\n \"updated\": \"2017-04-19T15:35:30.791Z\"\n },\n {\n \"owner\": \"eric-capps\",\n \"id\": \"zooblesnarb\",\n \"title\": \"zooblesnarb\",\n \"description\": \"test\",\n \"tags\": [\n \"bap\"\n ],\n \"visibility\": \"OPEN\",\n \"files\": [],\n \"created\": \"2016-11-02T21:18:58.696Z\",\n \"updated\": \"2016-11-11T16:56:30.714Z\"\n }\n ],\n \"next\": \"eyJyZXNvdXJjZSI6eyJzIjoiZGF0YXNldDplcmljLWNhcHBzL3pvb2JsZXNuYXJiIn0sInBhcnR5Ijp7InMiOiJhZ2VudDp1c2VyOCJ9fQ==\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "Fetch datasets that the currently authenticated user likes." - } - }, - "/user/datasets/own": { - "get": { - "tags": [ - "user" - ], - "summary": "List datasets as owner", - "operationId": "fetchDatasets", - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/limit" - }, - { - "$ref": "#/parameters/next" - } - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/PaginatedDatasetResults" - }, - "examples": { - "application/json": "{\n \"count\": 2,\n \"records\": [\n {\n \"owner\": \"bryonjacob\",\n \"id\": \"f-o-o\",\n \"title\": \"f-o-o\",\n \"description\": \"why do my datasets have to be at least 5 chars in length\",\n \"tags\": [],\n \"license\": \"CC-0\",\n \"visibility\": \"PRIVATE\",\n \"files\": [\n {\n \"name\": \"foo.csv\",\n \"sizeInBytes\": 56,\n \"created\": \"2016-06-09T21:56:06.943Z\",\n \"updated\": \"2016-06-09T21:56:06.943Z\"\n }\n ],\n \"status\": \"LOADED\",\n \"created\": \"2016-06-09T21:55:58.002Z\",\n \"updated\": \"2017-04-19T15:35:30.791Z\"\n },\n {\n \"owner\": \"eric-capps\",\n \"id\": \"zooblesnarb\",\n \"title\": \"zooblesnarb\",\n \"description\": \"test\",\n \"tags\": [\n \"bap\"\n ],\n \"visibility\": \"OPEN\",\n \"files\": [],\n \"created\": \"2016-11-02T21:18:58.696Z\",\n \"updated\": \"2016-11-11T16:56:30.714Z\"\n }\n ],\n \"next\": \"eyJyZXNvdXJjZSI6eyJzIjoiZGF0YXNldDplcmljLWNhcHBzL3pvb2JsZXNuYXJiIn0sInBhcnR5Ijp7InMiOiJhZ2VudDp1c2VyOCJ9fQ==\"\n}" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "security": [ - { - "token": [] - } - ], - "description": "Fetch datasets that the currently authenticated user has access to because he or she is the owner of the dataset." - } - }, - "/projects/{owner}/{id}": { - "get": { - "tags": [ - "projects" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/ProjectSummaryResponse" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "produces": [ - "application/json" - ], - "summary": "Retrieve a project", - "operationId": "getProject", - "security": [ - { - "token": [] - } - ], - "parameters": [ - { - "$ref": "#/parameters/projectOwner" - }, - { - "$ref": "#/parameters/projectId" - } - ], - "description": "Return details on a project." - }, - "put": { - "tags": [ - "projects" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "parameters": [ - { - "in": "body", - "name": "body", - "schema": { - "$ref": "#/definitions/ProjectCreateRequest" - } - }, - { - "$ref": "#/parameters/projectOwner" - }, - { - "$ref": "#/parameters/projectId" - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "summary": "Create / Replace a project", - "description": "Create a project with a given id or completely rewrite the project, including any previously added files or linked datasets, if one already exists with the given id.", - "operationId": "replaceProject", - "security": [ - { - "token": [] - } - ] - }, - "patch": { - "tags": [ - "projects" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "parameters": [ - { - "in": "body", - "name": "body", - "schema": { - "$ref": "#/definitions/ProjectPatchRequest" - } - }, - { - "$ref": "#/parameters/projectOwner" - }, - { - "$ref": "#/parameters/projectId" - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "summary": "Update a project", - "operationId": "patchProject", - "security": [ - { - "token": [] - } - ], - "description": "Update an existing project. Note that only elements, files or linked datasets included in the request will be updated. All omitted elements, files or linked datasets will remain untouched." - }, - "delete": { - "tags": [ - "projects" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "produces": [ - "application/json" - ], - "operationId": "deleteProject", - "security": [ - { - "token": [] - } - ], - "parameters": [ - { - "$ref": "#/parameters/projectOwner" - }, - { - "$ref": "#/parameters/projectId" - } - ], - "description": "Permanently deletes a project and all data associated with it. This operation cannot be undone, although a new project may be created with the same id.", - "summary": "Delete a project" - } - }, - "/projects/{owner}/{id}/linkedDatasets/{linkedDatasetOwner}/{linkedDatasetId}": { - "delete": { - "tags": [ - "projects" - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/SuccessMessage" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "produces": [ - "application/json" - ], - "summary": "Unlink dataset", - "operationId": "removeLinkedDataset", - "security": [ - { - "token": [] - } - ], - "parameters": [ - { - "$ref": "#/parameters/projectOwner" - }, - { - "$ref": "#/parameters/projectId" - }, - { - "name": "linkedDatasetOwner", - "in": "path", - "type": "string", - "required": true - }, - { - "name": "linkedDatasetId", - "in": "path", - "type": "string", - "required": true - } - ], - "description": "Remove a linked dataset from a project." - }, - "put": { - "tags": [ - "projects" - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/SuccessMessage" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "produces": [ - "application/json" - ], - "operationId": "addLinkedDataset", - "security": [ - { - "token": [] - } - ], - "parameters": [ - { - "$ref": "#/parameters/projectOwner" - }, - { - "$ref": "#/parameters/projectId" - }, - { - "name": "linkedDatasetOwner", - "in": "path", - "type": "string", - "required": true - }, - { - "name": "linkedDatasetId", - "in": "path", - "type": "string", - "required": true - } - ], - "summary": "Link dataset", - "description": "Add a linked dataset to a project." - } - }, - "/projects/{owner}": { - "post": { - "tags": [ - "projects" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/CreateProjectResponse" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "parameters": [ - { - "in": "body", - "name": "body", - "schema": { - "$ref": "#/definitions/ProjectCreateRequest" - } - }, - { - "$ref": "#/parameters/projectOwner" - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "token": [] - } - ], - "operationId": "createProject", - "summary": "Create a project", - "description": "Create a new project." - } - }, - "/insights/{projectOwner}/{projectId}/{id}": { - "get": { - "tags": [ - "insights" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/InsightSummaryResponse" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "produces": [ - "application/json" - ], - "summary": "Retrieve an insight", - "operationId": "getInsight", - "security": [ - { - "token": [] - } - ], - "parameters": [ - { - "$ref": "#/parameters/insightProjectOwner" - }, - { - "$ref": "#/parameters/insightProjectId" - }, - { - "$ref": "#/parameters/insightId" - } - ], - "description": "Retrieve an insight." - }, - "delete": { - "tags": [ - "insights" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "produces": [ - "application/json" - ], - "summary": "Delete an insight", - "operationId": "deleteInsight", - "security": [ - { - "token": [] - } - ], - "parameters": [ - { - "$ref": "#/parameters/insightProjectOwner" - }, - { - "$ref": "#/parameters/insightProjectId" - }, - { - "$ref": "#/parameters/insightId" - } - ], - "description": "Delete an existing insight." - }, - "put": { - "tags": [ - "insights" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "schema": { - "$ref": "#/definitions/InsightPutRequest" - } - }, - { - "$ref": "#/parameters/insightProjectOwner" - }, - { - "$ref": "#/parameters/insightProjectId" - }, - { - "$ref": "#/parameters/insightId" - } - ], - "summary": "Replace an insight", - "operationId": "replaceInsight", - "security": [ - { - "token": [] - } - ], - "description": "Replace an insight." - }, - "patch": { - "tags": [ - "insights" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/SuccessMessage" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "schema": { - "$ref": "#/definitions/InsightPatchRequest" - } - }, - { - "$ref": "#/parameters/insightProjectOwner" - }, - { - "$ref": "#/parameters/insightProjectId" - }, - { - "$ref": "#/parameters/insightId" - } - ], - "summary": "Update an insight", - "operationId": "updateInsight", - "security": [ - { - "token": [] - } - ], - "description": "Update an insight. Note that only elements included in the request will be updated. All omitted elements will remain untouched." - } - }, - "/insights/{projectOwner}/{projectId}": { - "get": { - "tags": [ - "insights" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/PaginatedInsightResults" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "produces": [ - "application/json" - ], - "parameters": [ - { - "$ref": "#/parameters/insightProjectOwner" - }, - { - "$ref": "#/parameters/insightProjectId" - }, - { - "$ref": "#/parameters/limit" - }, - { - "$ref": "#/parameters/next" - } - ], - "operationId": "getInsightsForProject", - "security": [ - { - "token": [] - } - ], - "summary": "Get insights for project.", - "description": "Get insights for a project." - }, - "post": { - "tags": [ - "insights" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/CreateInsightResponse" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "422": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNPROCESSABLE ENTITY**\nThe server understands the content type of the request entity and the syntax of the request entity is correct, but was unable to process the contained instructions.\nFor example, this error may occur if the JSON body of the request doesn't match the expected schema." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "schema": { - "$ref": "#/definitions/InsightCreateRequest" - } - }, - { - "$ref": "#/parameters/insightProjectOwner" - }, - { - "$ref": "#/parameters/insightProjectId" - } - ], - "operationId": "createInsight", - "security": [ - { - "token": [] - } - ], - "summary": "Create an insight", - "description": "Create a new insight." - } - }, - "/user/projects/own": { - "get": { - "tags": [ - "user" - ], - "responses": { - "200": { - "description": "**OK**\nThe request has succeeded.", - "schema": { - "$ref": "#/definitions/PaginatedProjectResults" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "produces": [ - "application/json" - ], - "description": "Fetch projects that the currently authenticated user has access to because he or she is the owner of the project.", - "summary": "List projects owned", - "operationId": "fetchProjects", - "security": [ - { - "token": [] - } - ] - } - }, - "/user/projects/liked": { - "get": { - "tags": [ - "user" - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/PaginatedProjectResults" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "produces": [ - "application/json" - ], - "summary": "List liked projects", - "description": "Fetch projects that the currently authenticated user likes.", - "operationId": "fetchLikedProjects", - "security": [ - { - "token": [] - } - ] - } - }, - "/user/projects/contributing": { - "get": { - "tags": [ - "user" - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/PaginatedProjectResults" - } - }, - "400": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**BAD REQUEST**\nThe server cannot or will not process the request due to something that is perceived to be a client error.\nFor example, this error may occur when the request doesn’t satisfy validation rules. See response for additional details." - }, - "401": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**UNAUTHORIZED**\nThe request has not been applied because it lacks valid authentication credentials for the target resource.\nFor example, this may occur if a token is invalid or hasn’t been provided. Make sure that you have a valid token and that is provided via the `Authorization` header including the `Bearer` prefix. For example, if your token is `xyz`, your header should be `Authorization: Bearer xyz`." - }, - "403": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**FORBIDDEN**\nThe server understood the request but refuses to authorize it.\nFor example, this error may occur you are not authorized to perform this operation." - }, - "404": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**NOT FOUND**\nThe origin server did not find a current representation for the target resource or is not willing to disclose that one exists.\nFor example, this error may occur when the URL is invalid." - }, - "500": { - "schema": { - "$ref": "#/definitions/ErrorMessage" - }, - "description": "**INTERNAL SERVER ERROR**\nThe server encountered an unexpected condition that prevented it from fulfilling the request." - } - }, - "produces": [ - "application/json" - ], - "summary": "List projects as contributor", - "description": "Fetch projects that the currently authenticated user has access to because he or she is a contributor.", - "operationId": "fetchContributingProjects", - "security": [ - { - "token": [] - } - ] - } - } - }, - "securityDefinitions": { - "token": { - "type": "apiKey", - "name": "Authorization", - "in": "header", - "description": "All data.world API calls require an API token. After logging into data.world, find your token by navigating to your profile settings, under the Advanced tab or go to [https://data.world/settings/advanced](*https://data.world/settings/advanced*)\n\nAuthentication must be provided in API requests via the `Authorization` header. For example, for a user whose API token is `my_api_token`, the request header should be `Authorization: Bearer my_api_token`." - } - }, - "definitions": { - "DatasetCreateRequest": { - "type": "object", - "title": "Dataset Create Request", - "properties": { - "title": { - "type": "string", - "minLength": 1, - "maxLength": 60, - "description": "Dataset name." - }, - "description": { - "type": "string", - "minLength": 0, - "maxLength": 120, - "description": "Short dataset description." - }, - "summary": { - "type": "string", - "minLength": 0, - "maxLength": 25000, - "description": "Long-form dataset summary (Markdown supported)." - }, - "tags": { - "type": "array", - "description": "Dataset tags. Letters numbers and spaces only (max 25 characters).", - "uniqueItems": true, - "items": { - "type": "string", - "maxLength": 25, - "pattern": "^[a-zA-Z0-9\\s]*" - } - }, - "license": { - "type": "string", - "description": "Dataset license. Find additional info for allowed values [here](https://data.world/license-help).", - "enum": [ - "Public Domain", - "PDDL", - "CC-0", - "CC-BY", - "ODC-BY", - "CC-BY-SA", - "ODC-ODbL", - "CC BY-NC", - "CC BY-NC-SA", - "Other" - ] - }, - "visibility": { - "type": "string", - "enum": [ - "OPEN", - "PRIVATE" - ], - "description": "Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators." - }, - "files": { - "type": "array", - "description": "Initial set of files. At dataset creation time, file uploads are not supported. However, this property can be used to add files via URL.", - "uniqueItems": false, - "items": { - "$ref": "#/definitions/FileCreateRequest" - } - } - }, - "required": [ - "title", - "visibility" - ] - }, - "DatasetPatchRequest": { - "type": "object", - "title": "Dataset Update Request", - "properties": { - "title": { - "type": "string", - "minLength": 0, - "maxLength": 60, - "description": "Dataset name." - }, - "description": { - "type": "string", - "minLength": 0, - "maxLength": 120, - "description": "Short dataset description." - }, - "summary": { - "type": "string", - "minLength": 0, - "maxLength": 25000, - "description": "Long-form dataset summary (Markdown supported)." - }, - "tags": { - "type": "array", - "description": "Dataset tags. Letters numbers and spaces only (max 25 characters).", - "uniqueItems": true, - "items": { - "type": "string", - "maxLength": 25, - "pattern": "^[a-zA-Z0-9\\s]*" - } - }, - "license": { - "type": "string", - "description": "Dataset license. Find additional info for allowed values [here](https://data.world/license-help).", - "enum": [ - "Public Domain", - "PDDL", - "CC-0", - "CC-BY", - "ODC-BY", - "CC-BY-SA", - "ODC-ODbL", - "CC BY-NC", - "CC BY-NC-SA", - "Other" - ] - }, - "visibility": { - "type": "string", - "enum": [ - "OPEN", - "PRIVATE" - ], - "description": "Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators." - }, - "files": { - "type": "array", - "description": "Updated set of files. At dataset update time, file uploads are not supported. However, this property can be used to add files from URL or update metadata related to existing files.", - "uniqueItems": false, - "items": { - "$ref": "#/definitions/FileCreateOrUpdateRequest" - } - } - } - }, - "DatasetPutRequest": { - "type": "object", - "title": "Dataset Replace Request", - "properties": { - "title": { - "type": "string", - "minLength": 1, - "maxLength": 60, - "description": "Dataset name." - }, - "description": { - "type": "string", - "minLength": 0, - "maxLength": 120, - "description": "Short dataset description." - }, - "summary": { - "type": "string", - "minLength": 0, - "maxLength": 25000, - "description": "Long-form dataset summary (Markdown supported)." - }, - "tags": { - "type": "array", - "description": "Dataset tags. Letters numbers and spaces only (max 25 characters).", - "uniqueItems": true, - "items": { - "type": "string", - "maxLength": 25, - "pattern": "^[a-zA-Z0-9\\s]*" - } - }, - "license": { - "type": "string", - "description": "Dataset license. Find additional info for allowed values [here](https://data.world/license-help).", - "enum": [ - "Public Domain", - "PDDL", - "CC-0", - "CC-BY", - "ODC-BY", - "CC-BY-SA", - "ODC-ODbL", - "CC BY-NC", - "CC BY-NC-SA", - "Other" - ] - }, - "visibility": { - "type": "string", - "enum": [ - "OPEN", - "PRIVATE" - ], - "description": "Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators." - }, - "files": { - "type": "array", - "description": "Initial set of files. At dataset creation time, file uploads are not supported. However, this property can be used to add files via URL.", - "uniqueItems": false, - "items": { - "$ref": "#/definitions/FileCreateRequest" - } - } - }, - "required": [ - "title", - "visibility" - ] - }, - "DatasetSummaryResponse": { - "type": "object", - "title": "Dataset Summary Response", - "properties": { - "owner": { - "type": "string", - "description": "User name and unique identifier of the creator of the dataset." - }, - "id": { - "type": "string", - "description": "Unique identifier of dataset." - }, - "title": { - "type": "string", - "description": "Dataset name." - }, - "description": { - "type": "string", - "description": "Short dataset description." - }, - "summary": { - "type": "string", - "description": "Long-form dataset summary (Markdown supported)." - }, - "tags": { - "type": "array", - "description": "Dataset tags. Letters numbers and spaces only (max 25 characters).", - "uniqueItems": true, - "items": { - "type": "string" - } - }, - "license": { - "type": "string", - "description": "Dataset license. Find additional info for allowed values [here](https://data.world/license-help)." - }, - "visibility": { - "type": "string", - "description": "Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators." - }, - "files": { - "type": "array", - "description": "Initial set of files. At dataset creation time, file uploads are not supported. However, this property can be used to add files via URL.", - "uniqueItems": false, - "items": { - "$ref": "#/definitions/FileSummaryResponse" - } - }, - "status": { - "type": "string", - "description": "Processing status of dataset. This status can be checked periodically after changes are made to the dataset to determine the status of asynchronous processing.\n\n* `NEW`: Just created. Not yet processed.\n* `INPROGRESS`: Currently being processed.\n* `LOADED`: Successfully processed.\n* `SYSTEMERROR`: Error state due to processing failure." - }, - "created": { - "type": "string", - "description": "Date and time when the dataset was created." - }, - "updated": { - "type": "string", - "description": "Date and time when the dataset was last updated." - }, - "isProject": { - "type": "boolean", - "description": "Every data project on data.world comes with a default dataset linked to it. This flag indicates if the dataset is a project's default dataset. " - }, - "accessLevel": { - "type": "string", - "description": "The level of access the authenticated user is allowed with respect to dataset: \n\n* `NONE` Not allowed any access. \n* `READ` Allowed to know that the dataset exists, view and download data and metadata. \n* `WRITE` Allowed to update data and metadata, in addition to what READ allows. \n* `ADMIN` Allowed to delete dataset, in addition to what WRITE allows." - } - }, - "required": [ - "owner", - "id", - "title", - "visibility", - "status", - "created", - "updated", - "isProject", - "accessLevel" - ] - }, - "ErrorMessage": { - "type": "object", - "title": "Error Message Response", - "properties": { - "code": { - "type": "integer", - "description": "HTTP Error Code", - "format": "int32" - }, - "message": { - "type": "string", - "description": "Human-readable error message." - }, - "details": { - "type": "string", - "description": "Underlying error cause." - } - } - }, - "FileBatchUpdateRequest": { - "type": "object", - "title": "File Create or Update Batch", - "properties": { - "files": { - "type": "array", - "description": "Updated set of files. When updating a set of files, file uploads are not supported. However, this property can be used to add files via URL or update metadata related to existing files.", - "items": { - "$ref": "#/definitions/FileCreateOrUpdateRequest" - } - } - } - }, - "FileCreateOrUpdateRequest": { - "type": "object", - "title": "File Create Or Update Request", - "description": "This model is utilized where sets of files can be specified to be added or updated (e.g. `PATCH:/dataset/{owner}` and `POST:/dataset/{owner}/{id}/files`).", - "properties": { - "name": { - "type": "string", - "minLength": 1, - "maxLength": 128, - "pattern": "^[^/]+$", - "description": "File name. Should include type extension always when possible. Must not include slashes." - }, - "source": { - "$ref": "#/definitions/FileSourceCreateOrUpdateRequest" - }, - "description": { - "type": "string", - "description": "File description.", - "minLength": 1, - "maxLength": 240 - }, - "labels": { - "type": "array", - "description": "File labels.", - "uniqueItems": true, - "items": { - "type": "string", - "enum": [ - "raw data", - "documentation", - "visualization", - "clean data", - "script", - "report" - ] - } - } - }, - "required": [ - "name" - ] - }, - "FileCreateRequest": { - "type": "object", - "title": "File Create Request", - "description": "This model is utilized where sets of files can be specified only to be added (e.g. `POST:/dataset/{owner}`).", - "properties": { - "name": { - "type": "string", - "minLength": 1, - "maxLength": 128, - "pattern": "^[^/]+$", - "description": "File name. Should include type extension always when possible. Must not include slashes." - }, - "source": { - "$ref": "#/definitions/FileSourceCreateRequest" - }, - "description": { - "type": "string", - "description": "File description.", - "minLength": 1, - "maxLength": 240 - }, - "labels": { - "type": "array", - "description": "File labels.", - "uniqueItems": true, - "items": { - "type": "string", - "enum": [ - "raw data", - "documentation", - "visualization", - "clean data", - "script", - "report" - ] - } - } - }, - "required": [ - "name", - "source" - ] - }, - "FileSourceCreateOrUpdateRequest": { - "type": "object", - "title": "File Source Create Or Update Request", - "description": "This model is utilized where source URLs can be specified for files to be added or updated.", - "properties": { - "url": { - "type": "string", - "description": "Source URL of file. Must be an http, https, or stream URL.", - "minLength": 1, - "maxLength": 4096, - "pattern": "^(https?|stream):.*", - "format": "uri" - }, - "method": { - "type": "string", - "enum": [ - "GET", - "POST" - ], - "default": "GET" - }, - "requestHeaders": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "A map of custom HTTP header name/value pairs to pass with the request.\n\nIf a `requestEntity` string is specified, this must contain a `Content-Type` header.\n\nAn `Authorization` header value will be converted to a `WebAuthorization` object and the credentials will be encrypted.\n\nThe total size of the url and custom headers must not exceed 4096 bytes in the HTTP request, including whitespace, colons and CRLF characters." - }, - "requestEntity": { - "type": "string", - "maxLength": 10000 - }, - "oauthToken": { - "$ref": "#/definitions/OauthTokenReference" - }, - "credentials": { - "$ref": "#/definitions/WebCredentials" - }, - "authorization": { - "$ref": "#/definitions/WebAuthorization" - }, - "expandArchive": { - "type": "boolean", - "default": false, - "description": "Indicates whether compressed files should be expanded upon upload." - } - }, - "required": [ - "url", - "method" - ] - }, - "FileSourceCreateRequest": { - "type": "object", - "description": "This model is utilized where source URLs can be specified for files only to be added.", - "title": "File Create Request", - "properties": { - "url": { - "type": "string", - "description": "Source URL of file. Must be an http, https.", - "minLength": 1, - "maxLength": 4096, - "pattern": "^https?:.*", - "format": "uri" - }, - "method": { - "type": "string", - "enum": [ - "GET", - "POST" - ], - "default": "GET" - }, - "requestHeaders": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "A map of custom HTTP header name/value pairs to pass with the request.\n\nIf a `requestEntity` string is specified, this must contain a `Content-Type` header.\n\nAn `Authorization` header value will be converted to a `WebAuthorization` object and the credentials will be encrypted.\n\nThe total size of the url and custom headers must not exceed 4096 bytes in the HTTP request, including whitespace, colons and CRLF characters." - }, - "requestEntity": { - "type": "string", - "maxLength": 10000 - }, - "oauthToken": { - "$ref": "#/definitions/OauthTokenReference" - }, - "credentials": { - "$ref": "#/definitions/WebCredentials" - }, - "authorization": { - "$ref": "#/definitions/WebAuthorization" - }, - "expandArchive": { - "type": "boolean", - "default": false, - "description": "Indicates whether compressed files should be expanded upon upload." - } - }, - "required": [ - "url", - "method" - ] - }, - "FileSourceSummaryResponse": { - "type": "object", - "title": "File Source Response", - "properties": { - "url": { - "type": "string", - "description": "Source URL of file. Must be an http, https, or stream URL.", - "format": "uri" - }, - "method": { - "type": "string" - }, - "requestHeaders": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "A map of custom HTTP header name/value pairs to pass with the request.\n\nIf a `requestEntity` string is specified, this must contain a `Content-Type` header." - }, - "requestEntity": { - "type": "string" - }, - "oauthToken": { - "$ref": "#/definitions/OauthTokenReference" - }, - "credentials": { - "$ref": "#/definitions/WebCredentials" - }, - "authorization": { - "$ref": "#/definitions/WebAuthorization" - }, - "syncStatus": { - "type": "string", - "description": "Synchronization status of the file. This status can be checked periodically after changes are made to the dataset to determine the status of asynchronous syncronization.\n\n* `NEW`: Just created. Not yet synchronized.\n* `INPROGRESS`: Currently being synchronized.\n* `LOADED`: Successfully synchronized.\n* `SYSTEMERROR`: Error state due to synchronization failure." - }, - "syncSummary": { - "type": "string", - "description": "Human-readable message detailing status of last failed sync." - }, - "lastSyncStart": { - "type": "string", - "description": "Date and time when synchronization last started." - }, - "lastSyncSuccess": { - "type": "string", - "description": "Date and time when synchronization last finished successfully." - }, - "lastSyncFailure": { - "type": "string", - "description": "Date and time when synchronization last failed." - } - }, - "required": [ - "url", - "method", - "syncStatus" - ] - }, - "FileSummaryResponse": { - "type": "object", - "title": "File Summary Response", - "properties": { - "name": { - "type": "string", - "description": "File name. Should include type extension always when possible. Must not include slashes." - }, - "source": { - "$ref": "#/definitions/FileSourceSummaryResponse" - }, - "description": { - "type": "string", - "description": "File description." - }, - "labels": { - "type": "array", - "description": "File labels.", - "uniqueItems": true, - "items": { - "type": "string" - } - }, - "sizeInBytes": { - "type": "integer", - "format": "int64" - }, - "created": { - "type": "string", - "description": "Date and time when file was created." - }, - "updated": { - "type": "string", - "description": "Date and time when file was last updated." - } - }, - "required": [ - "name", - "created", - "updated" - ] - }, - "SuccessMessage": { - "type": "object", - "properties": { - "message": { - "type": "string" - } - }, - "title": "Success Message Response" - }, - "UserDataResponse": { - "type": "object", - "title": "User Data Response", - "properties": { - "avatarUrl": { - "type": "string", - "description": "URL of profile image." - }, - "displayName": { - "type": "string", - "description": "User's name." - }, - "id": { - "type": "string", - "description": "User name and unique identifier." - }, - "created": { - "type": "string", - "description": "Date and time when account was created." - }, - "updated": { - "type": "string", - "description": "Date and time when account was last updated." - } - }, - "required": [ - "id", - "created", - "updated" - ] - }, - "CreateDatasetResponse": { - "type": "object", - "title": "Dataset Create Response", - "properties": { - "message": { - "type": "string" - }, - "uri": { - "type": "string", - "description": "URI of newly created dataset." - } - }, - "required": [ - "uri" - ] - }, - "PaginatedDatasetResults": { - "type": "object", - "title": "Paginated Dataset Results", - "properties": { - "count": { - "type": "integer", - "format": "int32", - "minimum": 0 - }, - "records": { - "type": "array", - "items": { - "$ref": "#/definitions/DatasetSummaryResponse" - } - }, - "nextPageToken": { - "type": "string" - } - }, - "required": [ - "count", - "records" - ] - }, - "ProjectCreateRequest": { - "type": "object", - "title": "Project Create Request", - "properties": { - "title": { - "type": "string", - "minLength": 0, - "maxLength": 60, - "description": "Project title." - }, - "objective": { - "type": "string", - "minLength": 0, - "maxLength": 120, - "description": "Short project objective." - }, - "summary": { - "type": "string", - "minLength": 0, - "maxLength": 25000, - "description": "Long-form project summary (Markdown supported)." - }, - "tags": { - "type": "array", - "description": "Project tags. Letters numbers and spaces only (max 25 characters).", - "uniqueItems": true, - "items": { - "type": "string", - "maxLength": 25, - "pattern": "^[a-zA-Z0-9\\s]*" - } - }, - "license": { - "type": "string", - "description": "Project license. Find additional info for allowed values [here](https://data.world/license-help).", - "enum": [ - "Public Domain", - "PDDL", - "CC-0", - "CC-BY", - "ODC-BY", - "CC-BY-SA", - "ODC-ODbL", - "CC BY-NC", - "CC BY-NC-SA", - "Other" - ] - }, - "visibility": { - "type": "string", - "enum": [ - "OPEN", - "PRIVATE" - ], - "description": "Project visibility. `OPEN` if the project can be seen by any member of data.world. `PRIVATE` if the project can be seen by its owner and authorized collaborators." - }, - "files": { - "type": "array", - "description": "Initial set of files. At project creation time, file uploads are not supported. However, this property can be used to add files from URL.", - "uniqueItems": false, - "items": { - "$ref": "#/definitions/FileCreateRequest" - } - }, - "linkedDatasets": { - "type": "array", - "description": "Initial set of linked datasets.", - "items": { - "$ref": "#/definitions/LinkedDatasetCreateOrUpdateRequest" - } - } - }, - "required": [ - "title", - "visibility" - ] - }, - "LinkedDatasetSummaryResponse": { - "type": "object", - "title": "Linked Dataset Summary Response", - "properties": { - "owner": { - "type": "string", - "description": "User name and unique identifier of the creator of the dataset." - }, - "id": { - "type": "string", - "description": "Unique identifier of dataset." - }, - "title": { - "type": "string", - "description": "Dataset name." - }, - "description": { - "type": "string", - "description": "Short dataset description." - }, - "summary": { - "type": "string", - "description": "Long-form dataset summary (Markdown supported)." - }, - "tags": { - "type": "array", - "description": "Dataset tags. Letters numbers and spaces only (max 25 characters).", - "uniqueItems": true, - "items": { - "type": "string" - } - }, - "license": { - "type": "string", - "description": "Dataset license. Find additional info for allowed values [here](https://data.world/license-help)." - }, - "visibility": { - "type": "string", - "description": "Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators." - }, - "created": { - "type": "string", - "description": "Date and time when the dataset was created." - }, - "updated": { - "type": "string", - "description": "Date and time when the dataset was last updated." - }, - "accessLevel": { - "type": "string", - "description": "The level of access the authenticated user is allowed with respect to dataset: \n\n* `NONE` Not allowed any access. \n* `READ` Allowed to know that the dataset exists, view and download data and metadata. \n* `WRITE` Allowed to update data and metadata, in addition to what READ allows. \n* `ADMIN` Allowed to delete dataset, in addition to what WRITE allows." - } - }, - "required": [ - "owner", - "id", - "title", - "visibility", - "created", - "updated", - "accessLevel" - ] - }, - "PaginatedProjectResults": { - "type": "object", - "title": "Paginated Project Results", - "properties": { - "count": { - "type": "integer", - "format": "int32" - }, - "records": { - "type": "array", - "items": { - "$ref": "#/definitions/ProjectSummaryResponse" - } - }, - "nextPageToken": { - "type": "string" - } - }, - "required": [ - "count", - "records" - ] - }, - "LinkedDatasetCreateOrUpdateRequest": { - "type": "object", - "title": "Linked Dataset Create or Update Request", - "properties": { - "owner": { - "type": "string", - "description": "User name and unique identifier of the creator of the dataset.", - "pattern": "[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]" - }, - "id": { - "type": "string", - "description": "Unique identifier of dataset.", - "pattern": "[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]" - } - }, - "required": [ - "owner", - "id" - ] - }, - "ProjectPatchRequest": { - "type": "object", - "title": "Project Update Request", - "properties": { - "title": { - "type": "string", - "minLength": 0, - "maxLength": 60, - "description": "Project title." - }, - "objective": { - "type": "string", - "minLength": 0, - "maxLength": 120, - "description": "Short project objective." - }, - "summary": { - "type": "string", - "minLength": 0, - "maxLength": 25000, - "description": "Long-form project summary (Markdown supported)." - }, - "tags": { - "type": "array", - "description": "Project tags. Letters numbers and spaces only (max 25 characters).", - "uniqueItems": true, - "items": { - "type": "string", - "maxLength": 25, - "pattern": "^[a-zA-Z0-9\\s]*" - } - }, - "license": { - "type": "string", - "description": "Project license. Find additional info for allowed values [here](https://data.world/license-help).", - "enum": [ - "Public Domain", - "PDDL", - "CC-0", - "CC-BY", - "ODC-BY", - "CC-BY-SA", - "ODC-ODbL", - "CC BY-NC", - "CC BY-NC-SA", - "Other" - ] - }, - "visibility": { - "type": "string", - "enum": [ - "OPEN", - "PRIVATE" - ], - "description": "Project visibility. `OPEN` if the project can be seen by any member of data.world. `PRIVATE` if the project can be seen by its owner and authorized collaborators." - }, - "files": { - "type": "array", - "description": "Updated set of files. At project update time, file uploads are not supported. However, this property can be used to add files from URL or update metadata related to existing files. Files included in this request will be added. Previously added files will be preserved without modification.", - "uniqueItems": false, - "items": { - "$ref": "#/definitions/FileCreateOrUpdateRequest" - } - }, - "linkedDatasets": { - "type": "array", - "description": "Updated set of linked datasets. Datasets linked in this request will be added. Previously linked datasets will be preserved without modification.", - "items": { - "$ref": "#/definitions/LinkedDatasetCreateOrUpdateRequest" - } - } - } - }, - "ProjectSummaryResponse": { - "type": "object", - "title": "Project Summary Response", - "properties": { - "title": { - "type": "string" - }, - "objective": { - "type": "string" - }, - "summary": { - "type": "string" - }, - "license": { - "type": "string" - }, - "tags": { - "type": "array", - "items": { - "type": "string" - } - }, - "files": { - "type": "array", - "items": { - "$ref": "#/definitions/FileSummaryResponse" - } - }, - "linkedDatasets": { - "type": "array", - "items": { - "$ref": "#/definitions/LinkedDatasetSummaryResponse" - } - }, - "visibility": { - "type": "string" - }, - "status": { - "type": "string", - "description": "Processing status of project. This status can be checked periodically after changes are made to the project to determine the status of asynchronous processing.\n\n* `NEW`: Just created. Not yet processed.\n* `INPROGRESS`: Currently being processed.\n* `LOADED`: Successfully processed.\n* `SYSTEMERROR`: Error state due to processing failure." - }, - "owner": { - "type": "string" - }, - "id": { - "type": "string" - }, - "created": { - "type": "string" - }, - "updated": { - "type": "string" - }, - "accessLevel": { - "type": "string" - } - }, - "required": [ - "title", - "visibility", - "status", - "owner", - "id", - "created", - "updated", - "accessLevel" - ] - }, - "CreateProjectResponse": { - "type": "object", - "title": "Project Create Response", - "properties": { - "message": { - "type": "string" - }, - "uri": { - "type": "string", - "description": "URI of newly created project." - } - }, - "required": [ - "uri" - ] - }, - "InsightCreateRequest": { - "type": "object", - "title": "Insight Create Request", - "properties": { - "title": { - "type": "string", - "minLength": 1, - "maxLength": 128, - "description": "Insight title." - }, - "description": { - "type": "string", - "maxLength": 150, - "description": "Insight description." - }, - "body": { - "$ref": "#/definitions/InsightBody" - }, - "sourceLink": { - "type": "string", - "format": "uri", - "description": "Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight." - }, - "dataSourceLinks": { - "type": "array", - "format": "uri", - "description": "One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight.", - "items": { - "format": "uri", - "type": "string" - } - } - }, - "required": [ - "body", - "title" - ] - }, - "InsightPutRequest": { - "type": "object", - "title": "Insight Replace Request", - "properties": { - "title": { - "type": "string", - "minLength": 1, - "maxLength": 128, - "description": "Insight title." - }, - "description": { - "type": "string", - "maxLength": 150, - "description": "Insight description." - }, - "body": { - "$ref": "#/definitions/InsightBody" - }, - "sourceLink": { - "type": "string", - "format": "uri", - "description": "Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight." - }, - "dataSourceLinks": { - "type": "array", - "format": "uri", - "description": "One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight.", - "items": { - "format": "uri", - "type": "string" - } - } - }, - "required": [ - "body", - "title" - ] - }, - "InsightSummaryResponse": { - "type": "object", - "title": "Insight Summary Response", - "properties": { - "id": { - "type": "string", - "description": "Unique Insight id." - }, - "title": { - "type": "string", - "description": "Insight title." - }, - "description": { - "type": "string", - "description": "Insight description." - }, - "body": { - "$ref": "#/definitions/InsightBody" - }, - "sourceLink": { - "type": "string", - "format": "uri", - "description": "Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight." - }, - "dataSourceLinks": { - "type": "array", - "format": "uri", - "description": "One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight.", - "items": { - "format": "uri", - "type": "string" - } - }, - "author": { - "type": "string", - "description": "User name of the author of the insight." - }, - "created": { - "type": "string", - "description": "Date and time when insight was created." - }, - "updated": { - "type": "string", - "description": "Date and time when insight was last updated." - } - }, - "required": [ - "id", - "title", - "body", - "author", - "created", - "updated" - ] - }, - "InsightPatchRequest": { - "type": "object", - "title": "Insight Update Request", - "properties": { - "title": { - "type": "string", - "minLength": 1, - "maxLength": 128, - "description": "Insight title." - }, - "description": { - "type": "string", - "maxLength": 150, - "description": "Insight description." - }, - "body": { - "$ref": "#/definitions/InsightBody" - }, - "sourceLink": { - "type": "string", - "format": "uri", - "description": "Permalink to source code or platform this insight was generated with. Allows others to replicate the steps originally used to produce the insight." - }, - "dataSourceLinks": { - "type": "array", - "format": "uri", - "description": "One or more permalinks to the data sources used to generate this insight. Allows others to access the data originally used to produce the insight.", - "items": { - "format": "uri", - "type": "string" - } - } - } - }, - "CreateInsightResponse": { - "type": "object", - "title": "Insight Create Response", - "properties": { - "message": { - "type": "string" - }, - "uri": { - "type": "string", - "description": "URI of newly created insight." - } - }, - "required": [ - "uri" - ] - }, - "PaginatedInsightResults": { - "type": "object", - "title": "Paginated Insight Results", - "properties": { - "count": { - "type": "integer", - "format": "int32" - }, - "records": { - "type": "array", - "items": { - "$ref": "#/definitions/InsightSummaryResponse" - } - }, - "nextPageToken": { - "type": "string" - } - }, - "required": [ - "count", - "records" - ] - }, - "InsightBody": { - "title": "Insight Body", - "type": "object", - "description": "Defines the body of an insight. Must contain one, and only one of: `imageUrl`, `embedUrl` or `markdownBody` (deprecated).", - "properties": { - "imageUrl": { - "type": "string", - "description": "Image URL", - "format": "uri" - }, - "embedUrl": { - "type": "string", - "description": "oEmbed URL.", - "format": "uri" - }, - "markdownBody": { - "type": "string", - "description": "Markdown (deprecated)" - } - } - }, - "WebCredentials": { - "type": "object", - "title": "Web Credentials", - "description": "A username and password suitable for use with HTTP Basic authentication.\n\nWhen used with a File Source this causes the HTTP request to include the following header:\n```\nAuthorization: Basic \n```\n\nThe `password` field is write-only. It is omitted by read operations.", - "properties": { - "user": { - "type": "string", - "description": "The name of the account to login to.", - "maxLength": 1024 - }, - "password": { - "type": "string", - "description": "The secret password.\n\nThis field is write-only. It is omitted by read operations.\n\nIf authorization is required, the `password` value must be provided whenever a File Source is created or modified. An update to a dataset that does not change the File Source may omit the `password` field--the update will preserve the previous value.", - "maxLength": 1024 - } - }, - "required": [ - "user" - ] - }, - "WebAuthorization": { - "type": "object", - "title": "Web Authorization", - "description": "An authorization type and credentials suitable for use in an HTTP `Authorization` header.\n\nWhen used with a File Source this causes the HTTP request to include the following header:\n```\nAuthorization: \n```\nThe `credentials` field is write-only. It is omitted by read operations.", - "properties": { - "type": { - "type": "string", - "description": "The authorization scheme.\n\nUsually this is \"Bearer\" but it could be other values like \"Token\" or \"Basic\" etc.", - "maxLength": 50, - "pattern": "[\\x21-\\x7E \\t]*" - }, - "credentials": { - "type": "string", - "description": "The confidential portion of the `Authorization` header that follows the `type` field.\n\nThis field is write-only. It is omitted by read operations.\n\nIf authorization is required, the `credentials` value must be provided whenever a File Source is created or modified. An update to a dataset that does not change the File Source may omit the `credentials` field--the update will preserve the previous value.", - "minLength": 1, - "maxLength": 1024, - "pattern": "[\\x21-\\x7E \\t]*" - } - }, - "required": [ - "type" - ] - }, - "OauthTokenReference": { - "type": "object", - "title": "OAuth Token Reference", - "description": "A reference to a 3rd-party OAuth 2.0 token stored by data.world.\n\nWhen creating or updating an OAuth token reference, the token must belong to the user making the update.", - "properties": { - "owner": { - "type": "string", - "minLength": 3, - "maxLength": 31, - "pattern": "[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]", - "description": "User name of the owner of the OAuth token within data.world." - }, - "site": { - "type": "string", - "minLength": 3, - "maxLength": 255, - "pattern": "(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?\\.)+[a-z]{2,}(?:@[a-z0-9](?:[-.](?=[a-z0-9])|[a-z0-9]){0,29})?" - }, - "id": { - "type": "string", - "format": "uuid" - } - }, - "required": [ - "owner", - "site", - "id" - ] - } - }, - "security": [ - { - "token": [] - } - ], - "parameters": { - "owner": { - "name": "owner", - "in": "path", - "type": "string", - "required": true, - "description": "User name and unique identifier of the creator of a dataset or project.\nFor example, in the URL: [https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), jonloyens is the unique identifier of the owner.", - "pattern": "[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]" - }, - "datasetId": { - "name": "id", - "in": "path", - "type": "string", - "required": true, - "description": "Dataset unique identifier.\nFor example, in the URL:[https://data.world/jonloyens/an-intro-to-dataworld-dataset](https://data.world/jonloyens/an-intro-to-dataworld-dataset), an-intro-to-dataworld-dataset is the unique identifier of the dataset.", - "pattern": "[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]" - }, - "file": { - "name": "file", - "in": "path", - "required": true, - "type": "string" - }, - "formQuery": { - "name": "query", - "in": "formData", - "required": true, - "type": "string" - }, - "includeTableSchema": { - "name": "includeTableSchema", - "in": "query", - "required": false, - "type": "boolean", - "default": false, - "description": "Flags indicating to include table schema in the response." - }, - "query": { - "name": "query", - "in": "query", - "required": true, - "type": "string" - }, - "limit": { - "name": "limit", - "in": "query", - "type": "string", - "description": "Maximum number of items to include in a page of results." - }, - "next": { - "name": "next", - "in": "query", - "type": "string", - "description": "Token from previous result page to be used when requesting a subsequent page." - }, - "streamId": { - "name": "streamId", - "in": "path", - "type": "string", - "description": "Stream unique identifier as defined by the user the first time the stream was used. Only lower case letters, numbers and dashes are allowed. Maximum length of 95 characters.", - "required": true, - "pattern": "[a-z0-9](?:-(?!-)|[a-z0-9]){1,93}[a-z0-9]" - }, - "projectOwner": { - "name": "owner", - "in": "path", - "type": "string", - "required": true, - "description": "User name and unique identifier of the creator of a project.\nFor example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), government is the unique identifier of the owner.", - "pattern": "[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]" - }, - "projectId": { - "name": "id", - "in": "path", - "type": "string", - "required": true, - "description": "Project unique identifier.\nFor example, in the URL:[https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), how-to-add-depth-to-your-data-with-the-us-census-acs is the unique identifier of the project.", - "pattern": "[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]" - }, - "insightProjectOwner": { - "name": "projectOwner", - "in": "path", - "type": "string", - "required": true, - "description": "User name and unique identifier of the creator of a project.\nFor example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `government` is the unique identifier of the owner.", - "pattern": "[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]" - }, - "insightProjectId": { - "name": "projectId", - "in": "path", - "type": "string", - "required": true, - "description": "User name and unique identifier of the project.\nFor example, in the URL: [https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs](https://data.world/government/how-to-add-depth-to-your-data-with-the-us-census-acs), `how-to-add-depth-to-your-data-with-the-us-census-acs` is the unique identifier of the owner.", - "pattern": "[a-z0-9](?:-(?!-)|[a-z0-9])+[a-z0-9]" - }, - "insightId": { - "name": "id", - "in": "path", - "type": "string", - "required": true, - "description": "Insight unique identifier." - } - } -} diff --git a/datadotworld/client/_swagger/models/project_summary_response.py b/datadotworld/models/project_summary_response.py similarity index 79% rename from datadotworld/client/_swagger/models/project_summary_response.py rename to datadotworld/models/project_summary_response.py index a31435d..3ebde31 100644 --- a/datadotworld/client/_swagger/models/project_summary_response.py +++ b/datadotworld/models/project_summary_response.py @@ -1,35 +1,9 @@ -# coding: utf-8 - -""" - data.world API - - data.world is designed for data and the people who work with data. From professional projects to open data, data.world helps you host and share your data, collaborate with your team, and capture context and conclusions as you work. Using this API users are able to easily access data and manage their data projects regardless of language or tool of preference. Check out our [documentation](https://dwapi.apidocs.io) for tips on how to get started, tutorials and to interact with the API right within your browser. - - OpenAPI spec version: 0.14.1 - Contact: help@data.world - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - from pprint import pformat from six import iteritems -import re class ProjectSummaryResponse(object): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ - - - """ - Attributes: - swagger_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ + swagger_types = { 'title': 'str', 'objective': 'str', @@ -64,11 +38,10 @@ class ProjectSummaryResponse(object): 'access_level': 'accessLevel' } - def __init__(self, title=None, objective=None, summary=None, license=None, tags=None, files=None, linked_datasets=None, visibility=None, status=None, owner=None, id=None, created=None, updated=None, access_level=None): - """ - ProjectSummaryResponse - a model defined in Swagger - """ - + def __init__(self, title=None, objective=None, summary=None, + license=None, tags=None, files=None, linked_datasets=None, + visibility=None, status=None, owner=None, id=None, + created=None, updated=None, access_level=None): self._title = None self._objective = None self._summary = None @@ -86,17 +59,17 @@ def __init__(self, title=None, objective=None, summary=None, license=None, tags= self.title = title if objective is not None: - self.objective = objective + self.objective = objective if summary is not None: - self.summary = summary + self.summary = summary if license is not None: - self.license = license + self.license = license if tags is not None: - self.tags = tags + self.tags = tags if files is not None: - self.files = files + self.files = files if linked_datasets is not None: - self.linked_datasets = linked_datasets + self.linked_datasets = linked_datasets self.visibility = visibility self.status = status self.owner = owner @@ -109,7 +82,6 @@ def __init__(self, title=None, objective=None, summary=None, license=None, tags= def title(self): """ Gets the title of this ProjectSummaryResponse. - :return: The title of this ProjectSummaryResponse. :rtype: str """ @@ -119,7 +91,6 @@ def title(self): def title(self, title): """ Sets the title of this ProjectSummaryResponse. - :param title: The title of this ProjectSummaryResponse. :type: str """ @@ -132,7 +103,6 @@ def title(self, title): def objective(self): """ Gets the objective of this ProjectSummaryResponse. - :return: The objective of this ProjectSummaryResponse. :rtype: str """ @@ -142,7 +112,6 @@ def objective(self): def objective(self, objective): """ Sets the objective of this ProjectSummaryResponse. - :param objective: The objective of this ProjectSummaryResponse. :type: str """ @@ -153,7 +122,6 @@ def objective(self, objective): def summary(self): """ Gets the summary of this ProjectSummaryResponse. - :return: The summary of this ProjectSummaryResponse. :rtype: str """ @@ -163,7 +131,6 @@ def summary(self): def summary(self, summary): """ Sets the summary of this ProjectSummaryResponse. - :param summary: The summary of this ProjectSummaryResponse. :type: str """ @@ -174,7 +141,6 @@ def summary(self, summary): def license(self): """ Gets the license of this ProjectSummaryResponse. - :return: The license of this ProjectSummaryResponse. :rtype: str """ @@ -184,7 +150,6 @@ def license(self): def license(self, license): """ Sets the license of this ProjectSummaryResponse. - :param license: The license of this ProjectSummaryResponse. :type: str """ @@ -195,7 +160,6 @@ def license(self, license): def tags(self): """ Gets the tags of this ProjectSummaryResponse. - :return: The tags of this ProjectSummaryResponse. :rtype: list[str] """ @@ -205,7 +169,6 @@ def tags(self): def tags(self, tags): """ Sets the tags of this ProjectSummaryResponse. - :param tags: The tags of this ProjectSummaryResponse. :type: list[str] """ @@ -216,7 +179,6 @@ def tags(self, tags): def files(self): """ Gets the files of this ProjectSummaryResponse. - :return: The files of this ProjectSummaryResponse. :rtype: list[FileSummaryResponse] """ @@ -226,7 +188,6 @@ def files(self): def files(self, files): """ Sets the files of this ProjectSummaryResponse. - :param files: The files of this ProjectSummaryResponse. :type: list[FileSummaryResponse] """ @@ -237,7 +198,6 @@ def files(self, files): def linked_datasets(self): """ Gets the linked_datasets of this ProjectSummaryResponse. - :return: The linked_datasets of this ProjectSummaryResponse. :rtype: list[LinkedDatasetSummaryResponse] """ @@ -246,9 +206,8 @@ def linked_datasets(self): @linked_datasets.setter def linked_datasets(self, linked_datasets): """ - Sets the linked_datasets of this ProjectSummaryResponse. - - :param linked_datasets: The linked_datasets of this ProjectSummaryResponse. + Sets the linked_datasets of ProjectSummaryResponse + :param linked_datasets: The linked_datasets of ProjectSummaryResponse :type: list[LinkedDatasetSummaryResponse] """ @@ -258,7 +217,6 @@ def linked_datasets(self, linked_datasets): def visibility(self): """ Gets the visibility of this ProjectSummaryResponse. - :return: The visibility of this ProjectSummaryResponse. :rtype: str """ @@ -268,21 +226,24 @@ def visibility(self): def visibility(self, visibility): """ Sets the visibility of this ProjectSummaryResponse. - :param visibility: The visibility of this ProjectSummaryResponse. :type: str """ if visibility is None: - raise ValueError("Invalid value for `visibility`, must not be `None`") - + raise ValueError("Invalid value for `visibility`, " + + "must not be `None`") self._visibility = visibility @property def status(self): """ Gets the status of this ProjectSummaryResponse. - Processing status of project. This status can be checked periodically after changes are made to the project to determine the status of asynchronous processing. * `NEW`: Just created. Not yet processed. * `INPROGRESS`: Currently being processed. * `LOADED`: Successfully processed. * `SYSTEMERROR`: Error state due to processing failure. - + Processing status of project. This status can be checked periodically + after changes are made to the project to determine the status of + asynchronous processing. * `NEW`: Just created. Not yet processed. + * `INPROGRESS`: Currently being processed. + * `LOADED`: Successfully processed. + * `SYSTEMERROR`: Error state due to processing failure. :return: The status of this ProjectSummaryResponse. :rtype: str """ @@ -292,21 +253,25 @@ def status(self): def status(self, status): """ Sets the status of this ProjectSummaryResponse. - Processing status of project. This status can be checked periodically after changes are made to the project to determine the status of asynchronous processing. * `NEW`: Just created. Not yet processed. * `INPROGRESS`: Currently being processed. * `LOADED`: Successfully processed. * `SYSTEMERROR`: Error state due to processing failure. - + Processing status of project. + This status can be checked periodically after changes are made to the + project to determine the status of asynchronous processing. + * `NEW`: Just created. Not yet processed. + * `INPROGRESS`: Currently being processed. + * `LOADED`: Successfully processed. + * `SYSTEMERROR`: Error state due to processing failure. :param status: The status of this ProjectSummaryResponse. :type: str """ if status is None: - raise ValueError("Invalid value for `status`, must not be `None`") - + raise ValueError("Invalid value for `status`, " + + "must not be `None`") self._status = status @property def owner(self): """ Gets the owner of this ProjectSummaryResponse. - :return: The owner of this ProjectSummaryResponse. :rtype: str """ @@ -316,7 +281,6 @@ def owner(self): def owner(self, owner): """ Sets the owner of this ProjectSummaryResponse. - :param owner: The owner of this ProjectSummaryResponse. :type: str """ @@ -329,7 +293,6 @@ def owner(self, owner): def id(self): """ Gets the id of this ProjectSummaryResponse. - :return: The id of this ProjectSummaryResponse. :rtype: str """ @@ -339,7 +302,6 @@ def id(self): def id(self, id): """ Sets the id of this ProjectSummaryResponse. - :param id: The id of this ProjectSummaryResponse. :type: str """ @@ -352,7 +314,6 @@ def id(self, id): def created(self): """ Gets the created of this ProjectSummaryResponse. - :return: The created of this ProjectSummaryResponse. :rtype: str """ @@ -362,20 +323,18 @@ def created(self): def created(self, created): """ Sets the created of this ProjectSummaryResponse. - :param created: The created of this ProjectSummaryResponse. :type: str """ if created is None: - raise ValueError("Invalid value for `created`, must not be `None`") - + raise ValueError("Invalid value for `created`, " + + "must not be `None`") self._created = created @property def updated(self): """ Gets the updated of this ProjectSummaryResponse. - :return: The updated of this ProjectSummaryResponse. :rtype: str """ @@ -385,20 +344,18 @@ def updated(self): def updated(self, updated): """ Sets the updated of this ProjectSummaryResponse. - :param updated: The updated of this ProjectSummaryResponse. :type: str """ if updated is None: - raise ValueError("Invalid value for `updated`, must not be `None`") - + raise ValueError("Invalid value for `updated`, " + + "must not be `None`") self._updated = updated @property def access_level(self): """ Gets the access_level of this ProjectSummaryResponse. - :return: The access_level of this ProjectSummaryResponse. :rtype: str """ @@ -408,13 +365,12 @@ def access_level(self): def access_level(self, access_level): """ Sets the access_level of this ProjectSummaryResponse. - :param access_level: The access_level of this ProjectSummaryResponse. :type: str """ if access_level is None: - raise ValueError("Invalid value for `access_level`, must not be `None`") - + raise ValueError("Invalid value for `access_level`," + + "must not be `None`") self._access_level = access_level def to_dict(self): diff --git a/datadotworld/util.py b/datadotworld/util.py index 07f62e2..0c90735 100644 --- a/datadotworld/util.py +++ b/datadotworld/util.py @@ -50,7 +50,7 @@ def parse_dataset_key(dataset_key): match = re.match(DATASET_KEY_PATTERN, dataset_key) if not match: raise ValueError('Invalid dataset key. Key must include user and ' - 'dataset names, separated by (i.e. user/dataset).') + 'dataset names, separated by / (i.e. user/dataset).') return match.groups() diff --git a/setup.cfg b/setup.cfg index 27eceea..48bdb44 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,12 +5,12 @@ universal=1 test=pytest [flake8] -exclude=datadotworld/client/_swagger/*, build, .eggs, .tox/* +exclude=build, .eggs, .tox/* [coverage:run] source=. data_file=.coverage -omit=datadotworld/client/_swagger/*, build, .eggs/* +omit=build, .eggs/* [coverage:report] -omit=datadotworld/client/_swagger/*, build, .eggs/* +omit=build, .eggs/* diff --git a/setup.py b/setup.py index 2976197..693469a 100644 --- a/setup.py +++ b/setup.py @@ -65,6 +65,7 @@ def find_version(*paths): 'Topic :: Software Development :: Libraries :: Python Modules', ], install_requires=[ + 'backoff>=1.3.0,<2.0a', 'certifi>=2017.04.17', 'click>=6.0,<7.0a', 'configparser>=3.5.0,<4.0a', @@ -75,7 +76,8 @@ def find_version(*paths): 'six>=1.5.0,<2.0a', 'tabulator<=1.4.1', 'urllib3>=1.15,<2.0a', - 'flake8>=2.6.0,<3.4.1a', + 'flake8>=2.6.0', + 'uplink>=0.5.5' ], setup_requires=[ 'pytest-runner>=2.11,<3.0a', diff --git a/tests/.DS_Store b/tests/.DS_Store new file mode 100644 index 0000000..4094c71 Binary files /dev/null and b/tests/.DS_Store differ diff --git a/tests/datadotworld/.DS_Store b/tests/datadotworld/.DS_Store new file mode 100644 index 0000000..852f6df Binary files /dev/null and b/tests/datadotworld/.DS_Store differ diff --git a/tests/datadotworld/client/test_client.py b/tests/datadotworld/client/test_client.py index 74cc973..1656b2a 100644 --- a/tests/datadotworld/client/test_client.py +++ b/tests/datadotworld/client/test_client.py @@ -1,483 +1,481 @@ -# data.world-py -# Copyright 2017 data.world, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the -# License. -# -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. See the License for the specific language governing -# permissions and limitations under the License. -# -# This product includes software developed at -# data.world, Inc.(http://data.world/). - -from __future__ import absolute_import - -import os -from os import path - -import pytest -import responses -from doublex import assert_that, Spy, called, Mock -from hamcrest import (equal_to, has_entries, has_properties, is_, described_as, - empty, raises, calling, has_key) - -from datadotworld.client._swagger import ( - DatasetsApi, - DownloadApi, - SparqlApi, - SqlApi, - UploadsApi, - UserApi, - StreamsApi, - ProjectsApi, - InsightsApi -) -from datadotworld.client._swagger.rest import ApiException -from datadotworld.client._swagger.models import ( - DatasetSummaryResponse, - FileBatchUpdateRequest, - FileCreateOrUpdateRequest, - FileSourceCreateOrUpdateRequest, - PaginatedDatasetResults, - UserDataResponse, - ProjectSummaryResponse, - InsightSummaryResponse, - PaginatedProjectResults -) -from datadotworld.client.api import RestApiClient, RestApiError - - -class TestApiClient: - @pytest.fixture() - def datasets_api(self): - with Spy(DatasetsApi) as api: - api.get_dataset = lambda o, d: DatasetSummaryResponse( - owner=o, - id=d, - title='Dataset', - visibility='PRIVATE', - status='LOADED', - created='2018-02-01T01:03:26.879Z', - updated='2018-02-01T01:03:28.211Z', - access_level='ADMIN', - is_project=False) - api.create_dataset_with_http_info = lambda o, b, **kwargs: ( - {}, 200, {'Location': 'https://data.world/agentid/datasetid'}) - return api - - @pytest.fixture() - def uploads_api(self): - with Spy(UploadsApi) as api: - return api - - @pytest.fixture() - def download_api(self): - with Spy(DownloadApi) as api: - api.download_dataset - api.download_file - return api - - @pytest.fixture() - def query_resp(self): - with Mock() as response: - response.data = 'result'.encode() - return response - - @pytest.fixture() - def sql_api(self, query_resp): - with Spy(SqlApi) as api: - api.sql_post = \ - lambda o, d, q, sql_api_mock, _preload_content: query_resp - return api - - @pytest.fixture() - def sparql_api(self, query_resp): - with Spy(SparqlApi) as api: - api.sparql_post = \ - lambda o, d, q, sparql_api_mock, _preload_content: query_resp - return api - - @pytest.fixture() - def user_api(self): - with Spy(UserApi) as api: - api.get_user_data = lambda: UserDataResponse( - id='test', - created='2018-02-01T01:03:26.879Z', - updated='2018-02-01T01:03:28.211Z') - api.fetch_liked_datasets = lambda: PaginatedDatasetResults( - count=1, - records=[]) - api.fetch_datasets = lambda: PaginatedDatasetResults(count=1, - records=[]) - api.fetch_contributing_datasets = lambda: PaginatedDatasetResults( - count=1, - records=[]) - api.fetch_contributing_projects = lambda: PaginatedProjectResults( - count=1, - records=[]) - api.fetch_liked_projects = lambda: PaginatedProjectResults( - count=1, - records=[]) - api.fetch_projects = lambda: PaginatedProjectResults(count=1, - records=[]) - return api - - @pytest.fixture() - def streams_api(self): - with Spy(StreamsApi) as api: - api.append_records - return api - - @pytest.fixture() - def projects_api(self): - with Spy(ProjectsApi) as api: - api.get_project = lambda o, d: ProjectSummaryResponse( - owner=o, - id=d, - title='Project', - visibility='PRIVATE', - status='LOADED', - created='2018-02-01T01:03:26.879Z', - updated='2018-02-01T01:03:28.211Z', - access_level='ADMIN') - api.create_project_with_http_info = lambda o, **kwargs: ( - {}, 200, {'Location': 'https://data.world/agentid/projectid'}) - return api - - @pytest.fixture() - def insights_api(self): - with Spy(InsightsApi) as api: - api.get_insight = lambda o, d, i: InsightSummaryResponse( - id=i, - title='Insights', - body={}, - author=o, - created='2018-02-01T01:03:26.879Z', - updated='2018-02-01T01:03:28.211Z') - api.create_insight_with_http_info = lambda o, d, **kwargs: ( - {}, 200, {'Location': 'https://data.world/agentid/projectid'}) - return api - - @pytest.fixture() - def api_client(self, config, datasets_api, uploads_api, download_api, - sql_api, sparql_api, user_api, streams_api, projects_api, - insights_api): - client = RestApiClient(config) - client._datasets_api = datasets_api - client._uploads_api = uploads_api - client._download_api = download_api - client._sql_api = sql_api - client._sparql_api = sparql_api - client._user_api = user_api - client._streams_api = streams_api - client._projects_api = projects_api - client._insights_api = insights_api - return client - - def test_get_dataset(self, api_client, dataset_key): - dataset = api_client.get_dataset(dataset_key) - assert_that(dataset, has_entries( - {'owner': equal_to('agentid'), 'id': equal_to('datasetid')})) - - def test_create_dataset(self, api_client): - create_request = {'title': 'Dataset', 'visibility': 'OPEN', - 'license': 'Public Domain'} - dataset_key = api_client.create_dataset('agentid', **create_request) - assert_that(dataset_key, - equal_to('https://data.world/agentid/datasetid')) - - def test_update_dataset(self, api_client, datasets_api, dataset_key): - patch_request = {'tags': ['tag1', 'tag2']} - api_client.update_dataset(dataset_key, **patch_request) - assert_that(datasets_api.patch_dataset, - called().times(1).with_args(equal_to('agentid'), - equal_to('datasetid'), - has_properties(patch_request))) - - def test_replace_dataset(self, api_client, datasets_api, dataset_key): - replace_request = {'title': 'Dataset', 'visibility': 'OPEN'} - api_client.replace_dataset(dataset_key, **replace_request) - assert_that(datasets_api.replace_dataset, - called().times(1).with_args(equal_to('agentid'), - equal_to('datasetid'), - has_properties( - replace_request))) - - def test_delete_dataset(self, api_client, datasets_api, dataset_key): - api_client.delete_dataset(dataset_key) - assert_that(datasets_api.delete_dataset, - called().times(1).with_args(equal_to('agentid'), - equal_to('datasetid'))) - - def test_add_files_via_url(self, api_client, datasets_api, dataset_key): - file_update_request = {'filename.ext': - {'url': 'https://acme.inc/filename.ext'}} - file_update_object = FileBatchUpdateRequest( - files=[FileCreateOrUpdateRequest( - name='filename.ext', - source=FileSourceCreateOrUpdateRequest( - url='https://acme.inc/filename.ext'))]) - - api_client.add_files_via_url(dataset_key, file_update_request) - assert_that(datasets_api.add_files_by_source, - called().times(1).with_args(equal_to('agentid'), - equal_to('datasetid'), - equal_to(file_update_object))) - - def test_sync_files(self, api_client, datasets_api, dataset_key): - api_client.sync_files(dataset_key) - assert_that(datasets_api.sync, - called().times(1).with_args('agentid', 'datasetid')) - - def test_upload_files(self, api_client, uploads_api, dataset_key): - files = ['filename.ext'] - api_client.upload_files(dataset_key, files) - assert_that(uploads_api.upload_files, - called().times(1).with_args(equal_to('agentid'), - equal_to('datasetid'), - equal_to(files))) - - def test_upload_file(self, api_client, uploads_api, dataset_key): - name = 'filename.ext' - api_client.upload_file(dataset_key, name) - assert_that(uploads_api.upload_file, - called().times(1).with_args(equal_to('agentid'), - equal_to('datasetid'), - equal_to(name))) - - def test_delete_files(self, api_client, datasets_api, dataset_key): - files = ['filename.ext'] - api_client.delete_files(dataset_key, files) - assert_that(datasets_api.delete_files_and_sync_sources, - called().times(1).with_args(equal_to('agentid'), - equal_to('datasetid'), - equal_to(files))) - - def test_rest_api_error(self): - apix = ApiException(status=400, reason="boom") - e = RestApiError(cause=apix) - assert_that(e.status, equal_to(400)) - assert_that(e.reason, equal_to("boom")) - assert_that(e.body, equal_to(None)) - assert_that(e.cause, equal_to(apix)) - - # TODO Test CRUD exception cases - - def test_download_datapackage(self, helpers, config, - test_datapackages_path, api_client, - dataset_key): - datapackage_zip = path.join(test_datapackages_path, - 'the-simpsons-by-the-data.zip') - with responses.RequestsMock() as rsps, open(datapackage_zip, - 'rb') as file: - @helpers.validate_request_headers() - def datapackage_endpoint(_): - return 200, {}, file.read() - - rsps.add_callback( - rsps.GET, - 'https://download.data.world/datapackage/agentid/datasetid', - datapackage_endpoint) - - datapackage = api_client.download_datapackage(dataset_key, - config.cache_dir) - - assert_that(datapackage, equal_to( - path.join(config.cache_dir, 'datapackage.json'))) - assert_that(path.isfile(datapackage), - described_as('%0 is a file', is_(True), datapackage)) - - data_subdirectory = path.join(config.cache_dir, 'data') - assert_that(path.isdir(data_subdirectory), - described_as('%0 is a directory', is_(True), - data_subdirectory)) - assert_that(os.listdir(config.tmp_dir), - described_as('%0 is empty', empty(), config.tmp_dir)) - - def test_download_datapackage_error(self, helpers, config, - test_datapackages_path, api_client, - dataset_key): - datapackage_zip = path.join(test_datapackages_path, - 'the-simpsons-by-the-data.zip') - with responses.RequestsMock() as rsps, open(datapackage_zip, - 'rb') as file: # noqa - @helpers.validate_request_headers() - def datapackage_endpoint(_): - return 400, {}, '' - - rsps.add_callback( - rsps.GET, - 'https://download.data.world/datapackage/agentid/datasetid', - datapackage_endpoint) - - assert_that( - calling(api_client.download_datapackage).with_args( - dataset_key, config.cache_dir), - raises(RestApiError)) - - def test_download_datapackage_existing_dest_dir( - self, config, api_client, dataset_key): - os.mkdir(config.cache_dir) - assert_that( - calling(api_client.download_datapackage).with_args( - dataset_key, config.cache_dir), - raises(ValueError)) - - def test_download_dataset(self, api_client, dataset_key, download_api): - api_client.download_dataset(dataset_key) - assert_that(download_api.download_dataset, - called().times(1).with_args('agentid', 'datasetid')) - - def test_download_file(self, api_client, dataset_key, download_api): - api_client.download_file(dataset_key, 'file') - assert_that(download_api.download_file, - called().times(1).with_args('agentid', 'datasetid', - 'file')) - - def test_sql(self, api_client, dataset_key, sql_api): - result = api_client.sql(dataset_key, 'query', sql_api_mock=sql_api) - assert_that(result.read().decode('utf-8'), equal_to('result')) - - def test_sparql(self, api_client, dataset_key, sparql_api): - result = api_client.sparql(dataset_key, 'query', - sparql_api_mock=sparql_api) - assert_that(result.read().decode('utf-8'), equal_to('result')) - - def test_get_user_data(self, api_client): - user_data_response = api_client.get_user_data() - assert_that(user_data_response, - has_key(equal_to('display_name'))) - - def test_fetch_liked_datasets(self, api_client, user_api): - liked_datasets = api_client.fetch_liked_datasets() - assert_that(user_api.fetch_liked_datasets(), - has_properties(liked_datasets)) - - def test_fetch_contributing_datasets(self, api_client, user_api): - contributing_datasets = api_client.fetch_contributing_datasets() - assert_that(user_api.fetch_contributing_datasets(), - has_properties(contributing_datasets)) - - def test_fetch_datasets(self, api_client, user_api): - user_datasets = api_client.fetch_datasets() - assert_that(user_api.fetch_datasets(), - has_properties(user_datasets)) - - def test_fetch_contributing_projects(self, api_client, user_api): - contributing_projects = api_client.fetch_contributing_projects() - assert_that(user_api.fetch_contributing_projects(), - has_properties(contributing_projects)) - - def test_fetch_liked_projects(self, api_client, user_api): - liked_projects = api_client.fetch_liked_projects() - assert_that(user_api.fetch_liked_projects(), - has_properties(liked_projects)) - - def test_fetch_projects(self, api_client, user_api): - projects = api_client.fetch_projects() - assert_that(user_api.fetch_projects(), has_properties(projects)) - - def test_append_records(self, api_client, dataset_key, streams_api): - body = {'content': 'content'} - api_client.append_records(dataset_key, 'streamid', body) - assert_that(streams_api.append_records, - called().times(1).with_args('agentid', 'datasetid', - 'streamid', body)) - - def test_get_project(self, api_client, project_key): - project = api_client.get_project(project_key) - assert_that(project, has_entries( - {'owner': equal_to('agentid'), 'id': equal_to('projectid')})) - - def test_create_project(self, api_client): - create_request = {'title': 'Project', 'visibility': 'OPEN'} - project_key = api_client.create_project('agentid', **create_request) - assert_that(project_key, - equal_to('https://data.world/agentid/projectid')) - - def test_update_project(self, api_client, projects_api, project_key): - update_request = {'tags': ['tag1', 'tag2']} - api_client.update_project(project_key, **update_request) - assert_that(projects_api.patch_project, - called().times(1)) - - def test_replace_project(self, api_client, projects_api, project_key): - replace_request = {'title': 'New Project', 'visibility': 'OPEN'} - api_client.replace_project(project_key, **replace_request) - assert_that(projects_api.replace_project, - called().times(1)) - - def test_add_linked_dataset(self, api_client, projects_api, project_key, - dataset_key): - api_client.add_linked_dataset(project_key, dataset_key) - assert_that(projects_api.add_linked_dataset, - called().times(1).with_args(equal_to('agentid'), - equal_to('projectid'), - equal_to('agentid'), - equal_to('datasetid'))) - - def test_remove_linked_dataset(self, api_client, projects_api, project_key, - dataset_key): - api_client.remove_linked_dataset(project_key, dataset_key) - assert_that(projects_api.remove_linked_dataset, - called().times(1).with_args(equal_to('agentid'), - equal_to('projectid'), - equal_to('agentid'), - equal_to('datasetid'))) - - def test_delete_project(self, api_client, projects_api, project_key): - api_client.delete_project(project_key) - assert_that(projects_api.delete_project, - called().times(1).with_args(equal_to('agentid'), - equal_to('projectid'))) - - def test_get_insight(self, api_client, project_key, - insight_id='insightid'): - insight = api_client.get_insight(project_key, insight_id) - assert_that(insight, has_entries( - {'author': equal_to('agentid'), 'id': equal_to(insight_id)})) - - def test_get_insight_for_project(self, api_client, insights_api, - project_key): - api_client.get_insights_for_project(project_key) - assert_that(insights_api.get_insights_for_project, - called().times(1).with_args(equal_to('agentid'), - equal_to('projectid'))) - - def test_create_insight(self, api_client, project_key): - create_request = {'title': 'Insight', 'image_url': 'https://image.url'} - new_insight = api_client.create_insight(project_key, - **create_request) - assert_that(new_insight, - equal_to('https://data.world/agentid/projectid')) - - def test_replace_insight(self, api_client, insights_api, project_key, - insight_id='insightid'): - replace_request = {'title': 'Replace Insight', - 'image_url': 'https://image.com/'} - api_client.replace_insight(project_key, insight_id, - **replace_request) - assert_that(insights_api.replace_insight, - called().times(1)) - - def test_update_insight(self, api_client, insights_api, project_key, - insight_id='insightid'): - patch_request = {'title': 'patch insight'} - api_client.update_insight(project_key, insight_id, **patch_request) - assert_that(insights_api.update_insight, - called().times(1)) - - def test_delete_insight(self, api_client, insights_api, project_key, - insight_id='insightid'): - api_client.delete_insight(project_key, insight_id) - assert_that(insights_api.delete_insight, - called().times(1).with_args(equal_to('agentid'), - equal_to('projectid'), - equal_to(insight_id))) +# # data.world-py +# # Copyright 2017 data.world, Inc. +# # +# # Licensed under the Apache License, Version 2.0 (the "License"); +# # you may not use this file except in compliance with the +# # License. +# # +# # You may obtain a copy of the License at +# # http://www.apache.org/licenses/LICENSE-2.0 +# # +# # Unless required by applicable law or agreed to in writing, software +# # distributed under the License is distributed on an "AS IS" BASIS, +# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# # implied. See the License for the specific language governing +# # permissions and limitations under the License. +# # +# # This product includes software developed at +# # data.world, Inc.(http://data.world/). +# +# from __future__ import absolute_import +# +# import os +# from os import path +# +# import pytest +# import responses +# from doublex import assert_that, Spy, called, Mock +# from hamcrest import (equal_to, has_entries, has_properties, is_, +# described_as, empty, raises, calling, has_key) +# +# from datadotworld import client +# +# from datadotworld.client._swagger.rest import ApiException +# from datadotworld.client._swagger.models import ( +# DatasetSummaryResponse, +# FileBatchUpdateRequest, +# FileCreateOrUpdateRequest, +# FileSourceCreateOrUpdateRequest, +# PaginatedDatasetResults, +# UserDataResponse, +# ProjectSummaryResponse, +# InsightSummaryResponse, +# PaginatedProjectResults +# ) +# from datadotworld.client.api import RestApiClient, RestApiError +# +# +# class TestApiClient: +# @pytest.fixture() +# def datasets_api(self): +# with Spy(DatasetsApi) as api: +# api.get_dataset = lambda o, d: DatasetSummaryResponse( +# owner=o, +# id=d, +# title='Dataset', +# visibility='PRIVATE', +# status='LOADED', +# created='2018-02-01T01:03:26.879Z', +# updated='2018-02-01T01:03:28.211Z', +# access_level='ADMIN', +# is_project=False) +# api.create_dataset_with_http_info = lambda o, b, **kwargs: ( +# {}, 200, +# {'Location':'https://data.world/agentid/datasetid'}) +# return api +# +# @pytest.fixture() +# def uploads_api(self): +# with Spy(UploadsApi) as api: +# return api +# +# @pytest.fixture() +# def download_api(self): +# with Spy(DownloadApi) as api: +# api.download_dataset +# api.download_file +# return api +# +# @pytest.fixture() +# def query_resp(self): +# with Mock() as response: +# response.data = 'result'.encode() +# return response +# +# @pytest.fixture() +# def sql_api(self, query_resp): +# with Spy(SqlApi) as api: +# api.sql_post = \ +# lambda o, d, q, sql_api_mock, _preload_content: query_resp +# return api +# +# @pytest.fixture() +# def sparql_api(self, query_resp): +# with Spy(SparqlApi) as api: +# api.sparql_post = \ +# lambda o, d, q, sparql_api_mock, +# _preload_content: query_resp +# return api +# +# @pytest.fixture() +# def user_api(self): +# with Spy(UserApi) as api: +# api.get_user_data = lambda: UserDataResponse( +# id='test', +# created='2018-02-01T01:03:26.879Z', +# updated='2018-02-01T01:03:28.211Z') +# api.fetch_liked_datasets = lambda: PaginatedDatasetResults( +# count=1, +# records=[]) +# api.fetch_datasets = lambda: PaginatedDatasetResults(count=1, +# records=[]) +# api.fetch_contributing_datasets = lambda: +# PaginatedDatasetResults( +# count=1, +# records=[]) +# api.fetch_contributing_projects = lambda: +# PaginatedProjectResults( +# count=1, +# records=[]) +# api.fetch_liked_projects = lambda: PaginatedProjectResults( +# count=1, +# records=[]) +# api.fetch_projects = lambda: \ +# PaginatedProjectResults(count=1, records=[]) +# return api +# +# @pytest.fixture() +# def streams_api(self): +# with Spy(StreamsApi) as api: +# api.append_records +# return api +# +# @pytest.fixture() +# def projects_api(self): +# with Spy(ProjectsApi) as api: +# api.get_project = lambda o, d: ProjectSummaryResponse( +# owner=o, +# id=d, +# title='Project', +# visibility='PRIVATE', +# status='LOADED', +# created='2018-02-01T01:03:26.879Z', +# updated='2018-02-01T01:03:28.211Z', +# access_level='ADMIN') +# api.create_project = lambda o, **kwargs: ( +# {}, 200, {'Location': 'https://data.world/agentid/' +# +'projectid'}) +# return api +# +# @pytest.fixture() +# def insights_api(self): +# with Spy(InsightsApi) as api: +# api.get_insight = lambda o, d, i: InsightSummaryResponse( +# id=i, +# title='Insights', +# body={}, +# author=o, +# created='2018-02-01T01:03:26.879Z', +# updated='2018-02-01T01:03:28.211Z') +# api.create_insight_with_http_info = lambda o, d, **kwargs: ( +# {}, 200, {'Location': 'https://data.world/agentid/' +# + 'projectid'}) +# return api +# +# @pytest.fixture() +# def api_client(self, config, datasets_api, uploads_api, download_api, +# sql_api, sparql_api, user_api, streams_api, projects_api, +# insights_api): +# client = RestApiClient(config) +# client._datasets_api = datasets_api +# client._uploads_api = uploads_api +# client._download_api = download_api +# client._sql_api = sql_api +# client._sparql_api = sparql_api +# client._user_api = user_api +# client._streams_api = streams_api +# client._projects_api = projects_api +# client._insights_api = insights_api +# return client +# +# def test_get_dataset(self, api_client, dataset_key): +# dataset = api_client.get_dataset(dataset_key) +# assert_that(dataset, has_entries( +# {'owner': equal_to('agentid'), 'id': equal_to('datasetid')})) +# +# def test_create_dataset(self, api_client): +# create_request = {'title': 'Dataset', 'visibility': 'OPEN', +# 'license': 'Public Domain'} +# dataset_key = api_client.create_dataset('agentid', **create_request) +# assert_that(dataset_key, +# equal_to('https://data.world/agentid/datasetid')) +# +# def test_update_dataset(self, api_client, datasets_api, dataset_key): +# patch_request = {'tags': ['tag1', 'tag2']} +# api_client.update_dataset(dataset_key, **patch_request) +# assert_that(datasets_api.patch_dataset, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('datasetid'), +# has_properties(patch_request))) +# +# def test_replace_dataset(self, api_client, datasets_api, dataset_key): +# replace_request = {'title': 'Dataset', 'visibility': 'OPEN'} +# api_client.replace_dataset(dataset_key, **replace_request) +# assert_that(datasets_api.replace_dataset, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('datasetid'), +# has_properties( +# replace_request))) +# +# def test_delete_dataset(self, api_client, datasets_api, dataset_key): +# api_client.delete_dataset(dataset_key) +# assert_that(datasets_api.delete_dataset, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('datasetid'))) +# +# def test_add_files_via_url(self, api_client, datasets_api, dataset_key): +# file_update_request = {'filename.ext': +# {'url': 'https://acme.inc/filename.ext'}} +# file_update_object = FileBatchUpdateRequest( +# files=[FileCreateOrUpdateRequest( +# name='filename.ext', +# source=FileSourceCreateOrUpdateRequest( +# url='https://acme.inc/filename.ext'))]) +# +# api_client.add_files_via_url(dataset_key, file_update_request) +# assert_that(datasets_api.add_files_by_source, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('datasetid'), +# equal_to(file_update_object))) +# +# def test_sync_files(self, api_client, datasets_api, dataset_key): +# api_client.sync_files(dataset_key) +# assert_that(datasets_api.sync, +# called().times(1).with_args('agentid', 'datasetid')) +# +# def test_upload_files(self, api_client, uploads_api, dataset_key): +# files = ['filename.ext'] +# api_client.upload_files(dataset_key, files) +# assert_that(uploads_api.upload_files, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('datasetid'), +# equal_to(files))) +# +# def test_upload_file(self, api_client, uploads_api, dataset_key): +# name = 'filename.ext' +# api_client.upload_file(dataset_key, name) +# assert_that(uploads_api.upload_file, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('datasetid'), +# equal_to(name))) +# +# def test_delete_files(self, api_client, datasets_api, dataset_key): +# files = ['filename.ext'] +# api_client.delete_files(dataset_key, files) +# assert_that(datasets_api.delete_files_and_sync_sources, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('datasetid'), +# equal_to(files))) +# +# def test_rest_api_error(self): +# apix = ApiException(status=400, reason="boom") +# e = RestApiError(cause=apix) +# assert_that(e.status, equal_to(400)) +# assert_that(e.reason, equal_to("boom")) +# assert_that(e.body, equal_to(None)) +# assert_that(e.cause, equal_to(apix)) +# +# # TODO Test CRUD exception cases +# +# def test_download_datapackage(self, helpers, config, +# test_datapackages_path, api_client, +# dataset_key): +# datapackage_zip = path.join(test_datapackages_path, +# 'the-simpsons-by-the-data.zip') +# with responses.RequestsMock() as rsps, open(datapackage_zip, +# 'rb') as file: +# @helpers.validate_request_headers() +# def datapackage_endpoint(_): +# return 200, {}, file.read() +# +# rsps.add_callback( +# rsps.GET, +# 'https://download.data.world/datapackage/agentid/datasetid', +# datapackage_endpoint) +# +# datapackage = api_client.download_datapackage(dataset_key, +# config.cache_dir) +# +# assert_that(datapackage, equal_to( +# path.join(config.cache_dir, 'datapackage.json'))) +# assert_that(path.isfile(datapackage), +# described_as('%0 is a file', is_(True), datapackage)) +# +# data_subdirectory = path.join(config.cache_dir, 'data') +# assert_that(path.isdir(data_subdirectory), +# described_as('%0 is a directory', is_(True), +# data_subdirectory)) +# assert_that(os.listdir(config.tmp_dir), +# described_as('%0 is empty', empty(), config.tmp_dir)) +# +# def test_download_datapackage_error(self, helpers, config, +# test_datapackages_path, api_client, +# dataset_key): +# datapackage_zip = path.join(test_datapackages_path, +# 'the-simpsons-by-the-data.zip') +# with responses.RequestsMock() as rsps, open(datapackage_zip, +# 'rb') as file: # noqa +# @helpers.validate_request_headers() +# def datapackage_endpoint(_): +# return 400, {}, '' +# +# rsps.add_callback( +# rsps.GET, +# 'https://download.data.world/datapackage/agentid/datasetid', +# datapackage_endpoint) +# +# assert_that( +# calling(api_client.download_datapackage).with_args( +# dataset_key, config.cache_dir), +# raises(RestApiError)) +# +# def test_download_datapackage_existing_dest_dir( +# self, config, api_client, dataset_key): +# os.mkdir(config.cache_dir) +# assert_that( +# calling(api_client.download_datapackage).with_args( +# dataset_key, config.cache_dir), +# raises(ValueError)) +# +# def test_download_dataset(self, api_client, dataset_key, download_api): +# api_client.download_dataset(dataset_key) +# assert_that(download_api.download_dataset, +# called().times(1).with_args('agentid', 'datasetid')) +# +# def test_download_file(self, api_client, dataset_key, download_api): +# api_client.download_file(dataset_key, 'file') +# assert_that(download_api.download_file, +# called().times(1).with_args('agentid', 'datasetid', +# 'file')) +# +# def test_sql(self, api_client, dataset_key, sql_api): +# result = api_client.sql(dataset_key, 'query', sql_api_mock=sql_api) +# assert_that(result.read().decode('utf-8'), equal_to('result')) +# +# def test_sparql(self, api_client, dataset_key, sparql_api): +# result = api_client.sparql(dataset_key, 'query', +# sparql_api_mock=sparql_api) +# assert_that(result.read().decode('utf-8'), equal_to('result')) +# +# def test_get_user_data(self, api_client): +# user_data_response = api_client.get_user_data() +# assert_that(user_data_response, +# has_key(equal_to('display_name'))) +# +# def test_fetch_liked_datasets(self, api_client, user_api): +# liked_datasets = api_client.fetch_liked_datasets() +# assert_that(user_api.fetch_liked_datasets(), +# has_properties(liked_datasets)) +# +# def test_fetch_contributing_datasets(self, api_client, user_api): +# contributing_datasets = api_client.fetch_contributing_datasets() +# assert_that(user_api.fetch_contributing_datasets(), +# has_properties(contributing_datasets)) +# +# def test_fetch_datasets(self, api_client, user_api): +# user_datasets = api_client.fetch_datasets() +# assert_that(user_api.fetch_datasets(), +# has_properties(user_datasets)) +# +# def test_fetch_contributing_projects(self, api_client, user_api): +# contributing_projects = api_client.fetch_contributing_projects() +# assert_that(user_api.fetch_contributing_projects(), +# has_properties(contributing_projects)) +# +# def test_fetch_liked_projects(self, api_client, user_api): +# liked_projects = api_client.fetch_liked_projects() +# assert_that(user_api.fetch_liked_projects(), +# has_properties(liked_projects)) +# +# def test_fetch_projects(self, api_client, user_api): +# projects = api_client.fetch_projects() +# assert_that(user_api.fetch_projects(), has_properties(projects)) +# +# def test_append_records(self, api_client, dataset_key, streams_api): +# body = {'content': 'content'} +# api_client.append_records(dataset_key, 'streamid', body) +# assert_that(streams_api.append_records, +# called().times(1).with_args('agentid', 'datasetid', +# 'streamid', body)) +# +# def test_get_project(self, api_client, project_key): +# project = api_client.projects.get_project(project_key) +# assert_that(project, has_entries( +# {'owner': equal_to('agentid'), 'id': equal_to('projectid')})) +# +# def test_create_project(self, api_client): +# create_request = {'title': 'Project', 'visibility': 'OPEN'} +# project_key = api_client.create_project('agentid', **create_request) +# assert_that(project_key, +# equal_to('https://data.world/agentid/projectid')) +# +# def test_update_project(self, api_client, projects_api, project_key): +# update_request = {'tags': ['tag1', 'tag2']} +# api_client.update_project(project_key, **update_request) +# assert_that(projects_api.patch_project, +# called().times(1)) +# +# def test_replace_project(self, api_client, projects_api, project_key): +# replace_request = {'title': 'New Project', 'visibility': 'OPEN'} +# api_client.replace_project(project_key, **replace_request) +# assert_that(projects_api.replace_project, +# called().times(1)) +# +# def test_add_linked_dataset(self, api_client, projects_api, project_key, +# dataset_key): +# api_client.add_linked_dataset(project_key, dataset_key) +# assert_that(projects_api.add_linked_dataset, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('projectid'), +# equal_to('agentid'), +# equal_to('datasetid'))) +# +# def test_remove_linked_dataset(self, api_client, projects_api, +# project_key, dataset_key): +# api_client.remove_linked_dataset(project_key, dataset_key) +# assert_that(projects_api.remove_linked_dataset, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('projectid'), +# equal_to('agentid'), +# equal_to('datasetid'))) +# +# def test_delete_project(self, api_client, projects_api, project_key): +# api_client.delete_project(project_key) +# assert_that(projects_api.delete_project, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('projectid'))) +# +# def test_get_insight(self, api_client, project_key, +# insight_id='insightid'): +# insight = api_client.get_insight(project_key, insight_id) +# assert_that(insight, has_entries( +# {'author': equal_to('agentid'), 'id': equal_to(insight_id)})) +# +# def test_get_insight_for_project(self, api_client, insights_api, +# project_key): +# api_client.get_insights_for_project(project_key) +# assert_that(insights_api.get_insights_for_project, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('projectid'))) +# +# def test_create_insight(self, api_client, project_key): +# create_request = {'title': 'Insight', 'image_url': +# 'https://image.url'} +# new_insight = api_client.create_insight(project_key, +# **create_request) +# assert_that(new_insight, +# equal_to('https://data.world/agentid/projectid')) +# +# def test_replace_insight(self, api_client, insights_api, project_key, +# insight_id='insightid'): +# replace_request = {'title': 'Replace Insight', +# 'image_url': 'https://image.com/'} +# api_client.replace_insight(project_key, insight_id, +# **replace_request) +# assert_that(insights_api.replace_insight, +# called().times(1)) +# +# def test_update_insight(self, api_client, insights_api, project_key, +# insight_id='insightid'): +# patch_request = {'title': 'patch insight'} +# api_client.update_insight(project_key, insight_id, **patch_request) +# assert_that(insights_api.update_insight, +# called().times(1)) +# +# def test_delete_insight(self, api_client, insights_api, project_key, +# insight_id='insightid'): +# api_client.delete_insight(project_key, insight_id) +# assert_that(insights_api.delete_insight, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('projectid'), +# equal_to(insight_id))) diff --git a/tests/datadotworld/client/test_client2.py b/tests/datadotworld/client/test_client2.py new file mode 100644 index 0000000..5552a90 --- /dev/null +++ b/tests/datadotworld/client/test_client2.py @@ -0,0 +1,114 @@ +# data.world-py +# Copyright 2017 data.world, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the +# License. +# +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# This product includes software developed at +# data.world, Inc.(http://data.world/). + +# from __future__ import absolute_import +# +# import pytest +# from doublex import assert_that, Spy, called +# from hamcrest import (equal_to, has_entries) +# +# from datadotworld.client.api_client import ApiClient +# from datadotworld.client.projects_api import ProjectsApi +# from datadotworld.models.project_summary_response import \ +# ProjectSummaryResponse +# +# +# class TestApiClient: +# @pytest.fixture() +# def projects_api(self): +# with Spy(ProjectsApi) as api: +# api.get_project = lambda o, d: ProjectSummaryResponse( +# owner=o, +# id=d, +# title='Project', +# visibility='PRIVATE', +# status='LOADED', +# created='2018-02-01T01:03:26.879Z', +# updated='2018-02-01T01:03:28.211Z', +# access_level='ADMIN') +# return api +# +# @pytest.fixture() +# def api_client(self, projects_api, api_token='just_a_test_token'): +# client = ApiClient(api_token) +# client.projects = projects_api +# return client +# +# def test_get_project(self, api_client, owner_id='agentid', +# project_id='projectid'): +# project = api_client.projects.get_project(owner_id, project_id) +# assert_that(project, has_entries( +# {'owner': equal_to('agentid'), 'id': equal_to('projectid')})) +# +# def test_create_project(self, api_client): +# create_request = {'title': 'Project', 'visibility': 'OPEN'} +# project_key = api_client.projects.create_project('agentid', +# **create_request) +# assert_that(project_key, equal_to('https://data.world/' +# + 'agentid/projectid')) +# +# def test_update_project(self, api_client, projects_api, +# owner_id='agentid', project_id='projectid'): +# update_request = {'tags': ['tag1', 'tag2']} +# api_client.projects.patch_project(owner_id, project_id, +# **update_request) +# assert_that(projects_api.patch_project, +# called().times(1)) +# +# def test_replace_project(self, api_client, projects_api, +# owner_id='agentid', project_id='projectid'): +# replace_request = {'title': 'New Project', 'visibility': 'OPEN'} +# api_client.projects.replace_project(owner_id, project_id, +# **replace_request) +# assert_that(projects_api.replace_project, +# called().times(1)) +# +# def test_add_linked_dataset(self, api_client, projects_api, +# owner_id='agentid', project_id='projectid', +# linked_dataset_owner='agentid', +# linked_dataset_id='projectid'): +# api_client.projects.add_linked_dataset(owner_id, project_id, +# linked_dataset_owner, +# linked_dataset_id) +# assert_that(projects_api.add_linked_dataset, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('projectid'), +# equal_to('agentid'), +# equal_to('datasetid'))) +# +# def test_remove_linked_dataset(self, api_client, projects_api, +# owner_id='agentid', +# project_id='projectid', +# linked_dataset_owner='agentid', +# linked_dataset_id='projectid'): +# api_client.projects.remove_linked_dataset(owner_id, project_id, +# linked_dataset_owner, +# linked_dataset_id) +# assert_that(projects_api.remove_linked_dataset, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('projectid'), +# equal_to('agentid'), +# equal_to('datasetid'))) +# +# def test_delete_project(self, api_client, projects_api, +# owner_id='agentid', project_id='projectid'): +# api_client.projects.delete_project(owner_id, project_id) +# assert_that(projects_api.delete_project, +# called().times(1).with_args(equal_to('agentid'), +# equal_to('projectid'))) diff --git a/tests/datadotworld/test_datadotworld.py b/tests/datadotworld/test_datadotworld.py index f6448f5..ec35b5e 100644 --- a/tests/datadotworld/test_datadotworld.py +++ b/tests/datadotworld/test_datadotworld.py @@ -1,299 +1,301 @@ -# data.world-py -# Copyright 2017 data.world, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the -# License. -# -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. See the License for the specific language governing -# permissions and limitations under the License. -# -# This product includes software developed at -# data.world, Inc.(http://data.world/). - -from __future__ import absolute_import - -import json -import os -import re -import shutil -import warnings -from os import path - -import pytest -import responses -from doublex import assert_that, Spy, when, called, never, Stub -from hamcrest import ( - equal_to, calling, - raises, - has_length, - anything, - contains_string, - is_ -) - -import datadotworld -from datadotworld.client.api import RestApiClient, RestApiError -from datadotworld.datadotworld import DataDotWorld -from datadotworld.files import RemoteFile - - -class TestDataDotWorld: - @pytest.fixture() - def query_response_json(self, test_queries_path): - with open(path.join(test_queries_path, 'sql_select.json'), - 'r') as json_results: - return json.load(json_results) - - @pytest.fixture() - def existing_dataset(self, config, test_datapackages_path): - # Previously downloaded - dest_dir = path.join(config.cache_dir, 'agentid', 'datasetid', - 'latest') - shutil.copytree( - path.join(test_datapackages_path, - 'the-simpsons-by-the-data-existing'), - dest_dir) - - @pytest.fixture() - def api_client(self, test_datapackages_path): - with Spy(RestApiClient) as client: - def download_datapackage(_, dest_dir): - shutil.copytree( - path.join(test_datapackages_path, - 'the-simpsons-by-the-data'), - dest_dir) - return path.join(dest_dir, 'datapackage.json') - - def get_dataset(_): - return {'updated': '2016-11-07T00:00:00.000Z'} - - client.download_datapackage(anything(), anything()).delegates( - download_datapackage) - client.get_dataset(anything()).delegates( - get_dataset) - return client - - @pytest.fixture() - def dw(self, config, api_client): - dw = DataDotWorld(config=config) - dw.api_client = api_client - return dw - - query_types = [ - # Using proper queries here trips the responses framework when they - # are url-encoded and causes tests to fail - ('sparql', 'https://query.data.world/sparql/agentid/datasetid', - 'notreallysparql'), - ('sql', 'https://query.data.world/sql/agentid/datasetid', - 'notreallysql') - ] - - @pytest.mark.parametrize("type,endpoint,query", query_types, - ids=['sparql', 'sql']) - def test_query(self, helpers, dw, dataset_key, type, endpoint, query, - query_response_json): - with responses.RequestsMock() as rsps: - @helpers.validate_request_headers() - def query_endpoint(_): - return 200, {}, json.dumps(query_response_json) - - rsps.add_callback(rsps.GET, '{}?query={}'.format(endpoint, query), - content_type='text/csv', - callback=query_endpoint, match_querystring=True) - - result = dw.query(dataset_key, query, query_type=type) - assert_that(result.raw_data, equal_to(query_response_json)) - - @pytest.mark.parametrize("type,endpoint,query", query_types, - ids=['sparql', 'sql']) - def test_query_400(self, dw, dataset_key, type, endpoint, query): - with responses.RequestsMock() as rsps: - rsps.add(rsps.GET, '{}?query={}'.format(endpoint, query), - match_querystring=True, - status=400) - - assert_that(calling(dw.query).with_args(dataset_key, query, - query_type=type), - raises(RuntimeError)) - - parameterized_queries = [ - ('sql', 'notreallysql', ["USA", 10, 100.0, False], - [ - '%24data_world_param3%3D%22false%22%5E%5E%3Chttp%3A%2F%2F' - 'www.w3.org%2F2001%2FXMLSchema%23boolean%3E', - '%24data_world_param2%3D%22100.0%22%5E%5E%3Chttp%3A%2F%2F' - 'www.w3.org%2F2001%2FXMLSchema%23decimal%3E', - '%24data_world_param1%3D%2210%22%5E%5E%3Chttp%3A%2F%2F' - 'www.w3.org%2F2001%2FXMLSchema%23integer%3E', - '%24data_world_param0%3D%22USA%22' - ] - ), - ('sparql', 'notreallysparql', - { - '$aString': "USA", - '$anInt': 10, - '$aDecimal': 100.0, - '$aBool': False, - '$uUri': datadotworld.UriParam( - 'https://example.com/something#something') - }, - [ - '%24anInt%3D%2210%22%5E%5E%3Chttp%3A%2F%2F' - 'www.w3.org%2F2001%2FXMLSchema%23integer%3E', - '%24aDecimal%3D%22100.0%22%5E%5E%3Chttp%3A%2F%2F' - 'www.w3.org%2F2001%2FXMLSchema%23decimal%3E', - '%24aString%3D%22USA%22', - '%24aBool%3D%22false%22%5E%5E%3Chttp%3A%2F%2F' - 'www.w3.org%2F2001%2FXMLSchema%23boolean%3E', - '%3Chttps%3A%2F%2Fexample.com%2Fsomething%23something%3E' - ] - ) - ] - - @pytest.mark.parametrize("type,query,parameters,expected", - parameterized_queries) - def test_parameterized_queries(self, type, query, parameters, expected, - dw, dataset_key, query_response_json): - with responses.RequestsMock() as rsps: - def request_callback(request): - for value in expected: - assert_that(request.url, contains_string(value), - reason="Expected [[\n{}\n]] to contain " - "[[\n{}\n]]".format(request.url, expected)) - return(200, {}, json.dumps(query_response_json)) - - rsps.add_callback(rsps.GET, re.compile( - r'https?://query\.data\.world/.*'), - callback=request_callback, - content_type="application/json", - match_querystring=True) - - dw.query(dataset_key, query, query_type=type, - parameters=parameters) - - def test_load_dataset(self, config, api_client, dw, dataset_key): - dest_dir = path.join(config.cache_dir, 'agentid', 'datasetid', - 'latest') - assert_that(path.isdir(dest_dir), is_(False)) - - dataset = dw.load_dataset(dataset_key) - - assert_that(api_client.download_datapackage, - called().times(1).with_args(equal_to(dataset_key), - equal_to(dest_dir))) - assert_that(dataset.raw_data, has_length(4)) - - def test_open_file_writer(self, dw, dataset_key): - file_name = 'filename.ext' - with responses.RequestsMock() as resp: - resp.add(resp.PUT, re.compile('.*'), - body='{}', status=200, content_type='application/json') - w = dw.open_remote_file(dataset_key, file_name) - assert_that(isinstance(w, RemoteFile)) - try: - w.open() - finally: - w.close() - - @pytest.mark.usefixtures('existing_dataset') - def test_load_dataset_existing(self, api_client, dw, dataset_key): - with warnings.catch_warnings(record=True) as w: - dataset = dw.load_dataset(dataset_key) - assert_that(w, has_length(0)) - assert_that(api_client.download_datapackage, never(called())) - assert_that(dataset.raw_data, has_length(3)) - - @pytest.mark.usefixtures('existing_dataset') - def test_load_dataset_existing_expired(self, monkeypatch, api_client, dw, - dataset_key): - monkeypatch.setattr(os.path, 'getmtime', lambda _: 1468195199) - with warnings.catch_warnings(record=True) as w: - dataset = dw.load_dataset(dataset_key) - assert_that(w, has_length(1)) - assert_that(w[-1].category, equal_to(UserWarning)) - - assert_that(api_client.download_datapackage, never(called())) - assert_that(dataset.raw_data, has_length(3)) - - @pytest.mark.usefixtures('existing_dataset') - def test_load_dataset_existing_forced(self, api_client, dw, dataset_key): - dataset = dw.load_dataset(dataset_key, force_update=True) - - assert_that(api_client.download_datapackage, - called().times(1).with_args(equal_to(dataset_key), - anything())) - assert_that(dataset.raw_data, has_length(4)) - - @pytest.mark.usefixtures('existing_dataset') - def test_load_dataset_forced_fallback(self, api_client, dw, dataset_key): - when(api_client).download_datapackage(equal_to(dataset_key), - anything()).raises(RestApiError) - - # Forced update - with pytest.warns(UserWarning): - dataset = dw.load_dataset(dataset_key, force_update=True) - assert_that(api_client.download_datapackage, - called().times(1).with_args(equal_to(dataset_key), - anything())) - assert_that(dataset.raw_data, has_length(3)) - - @pytest.mark.usefixtures('existing_dataset') - def test_load_dataset_existing_expired_auto_update(self, monkeypatch, - api_client, dw, - dataset_key): - monkeypatch.setattr(os.path, 'getmtime', lambda _: 1468195199) - dataset = dw.load_dataset(dataset_key, auto_update=True) - assert_that(api_client.download_datapackage, - called().times(1).with_args(equal_to(dataset_key), - anything())) - assert_that(dataset.raw_data, has_length(4)) - - -# Top-level methods - -@pytest.fixture() -def dw_instances(monkeypatch): - import datadotworld - with Spy(DataDotWorld) as dw, Spy(DataDotWorld) as dw_alternative: - dw.api_client = dw_alternative.api_client = Stub(RestApiClient) - monkeypatch.setattr( - datadotworld, '_get_instance', - lambda profile: dw if profile == 'default' else dw_alternative) - return {'default': dw, 'alternative': dw_alternative} - - -@pytest.fixture(params=['default', 'alternative'], - ids=['default', 'alternative']) -def profile(request): - return request.param - - -def test_toplevel_load_dataset(dw_instances, profile): - datadotworld.load_dataset('agentid/datasetid', profile=profile) - assert_that(dw_instances[profile].load_dataset, - called().times(1).with_args(equal_to('agentid/datasetid'), - force_update=equal_to(False))) - assert_that(dw_instances[profile].load_dataset, - called().times(1).with_args(equal_to('agentid/datasetid'), - auto_update=equal_to(False))) - - -def test_toplevel_query(dw_instances, profile): - datadotworld.query('agentid/datasetid', 'SELECT * FROM Tables', - profile=profile) - assert_that(dw_instances[profile].query, - called().times(1).with_args(equal_to('agentid/datasetid'), - equal_to('SELECT * FROM Tables'), - query_type=equal_to('sql'))) - - -def test_toplevel_api_client(dw_instances, profile): - assert_that(datadotworld.api_client(), - equal_to(dw_instances[profile].api_client)) +# # data.world-py +# # Copyright 2017 data.world, Inc. +# # +# # Licensed under the Apache License, Version 2.0 (the "License"); +# # you may not use this file except in compliance with the +# # License. +# # +# # You may obtain a copy of the License at +# # http://www.apache.org/licenses/LICENSE-2.0 +# # +# # Unless required by applicable law or agreed to in writing, software +# # distributed under the License is distributed on an "AS IS" BASIS, +# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# # implied. See the License for the specific language governing +# # permissions and limitations under the License. +# # +# # This product includes software developed at +# # data.world, Inc.(http://data.world/). +# +# from __future__ import absolute_import +# +# import json +# import os +# import re +# import shutil +# import warnings +# from os import path +# +# import pytest +# import responses +# from doublex import assert_that, Spy, when, called, never, Stub +# from hamcrest import ( +# equal_to, calling, +# raises, +# has_length, +# anything, +# contains_string, +# is_ +# ) +# +# import datadotworld +# from datadotworld.client.api import RestApiClient, RestApiError +# from datadotworld.datadotworld import DataDotWorld +# from datadotworld.files import RemoteFile +# +# +# class TestDataDotWorld: +# @pytest.fixture() +# def query_response_json(self, test_queries_path): +# with open(path.join(test_queries_path, 'sql_select.json'), +# 'r') as json_results: +# return json.load(json_results) +# +# @pytest.fixture() +# def existing_dataset(self, config, test_datapackages_path): +# # Previously downloaded +# dest_dir = path.join(config.cache_dir, 'agentid', 'datasetid', +# 'latest') +# shutil.copytree( +# path.join(test_datapackages_path, +# 'the-simpsons-by-the-data-existing'), +# dest_dir) +# +# @pytest.fixture() +# def api_client(self, test_datapackages_path): +# with Spy(RestApiClient) as client: +# def download_datapackage(_, dest_dir): +# shutil.copytree( +# path.join(test_datapackages_path, +# 'the-simpsons-by-the-data'), +# dest_dir) +# return path.join(dest_dir, 'datapackage.json') +# +# def get_dataset(_): +# return {'updated': '2016-11-07T00:00:00.000Z'} +# +# client.download_datapackage(anything(), anything()).delegates( +# download_datapackage) +# client.get_dataset(anything()).delegates( +# get_dataset) +# return client +# +# @pytest.fixture() +# def dw(self, config, api_client): +# dw = DataDotWorld(config=config) +# dw.api_client = api_client +# return dw +# +# query_types = [ +# # Using proper queries here trips the responses framework when they +# # are url-encoded and causes tests to fail +# ('sparql', 'https://query.data.world/sparql/agentid/datasetid', +# 'notreallysparql'), +# ('sql', 'https://query.data.world/sql/agentid/datasetid', +# 'notreallysql') +# ] +# +# @pytest.mark.parametrize("type,endpoint,query", query_types, +# ids=['sparql', 'sql']) +# def test_query(self, helpers, dw, dataset_key, type, endpoint, query, +# query_response_json): +# with responses.RequestsMock() as rsps: +# @helpers.validate_request_headers() +# def query_endpoint(_): +# return 200, {}, json.dumps(query_response_json) +# +# rsps.add_callback(rsps.GET, +# '{}?query={}'.format(endpoint, query), +# content_type='text/csv', +# callback=query_endpoint, +# match_querystring=True) +# +# result = dw.query(dataset_key, query, query_type=type) +# assert_that(result.raw_data, equal_to(query_response_json)) +# +# @pytest.mark.parametrize("type,endpoint,query", query_types, +# ids=['sparql', 'sql']) +# def test_query_400(self, dw, dataset_key, type, endpoint, query): +# with responses.RequestsMock() as rsps: +# rsps.add(rsps.GET, '{}?query={}'.format(endpoint, query), +# match_querystring=True, +# status=400) +# +# assert_that(calling(dw.query).with_args(dataset_key, query, +# query_type=type), +# raises(RuntimeError)) +# +# parameterized_queries = [ +# ('sql', 'notreallysql', ["USA", 10, 100.0, False], +# [ +# '%24data_world_param3%3D%22false%22%5E%5E%3Chttp%3A%2F%2F' +# 'www.w3.org%2F2001%2FXMLSchema%23boolean%3E', +# '%24data_world_param2%3D%22100.0%22%5E%5E%3Chttp%3A%2F%2F' +# 'www.w3.org%2F2001%2FXMLSchema%23decimal%3E', +# '%24data_world_param1%3D%2210%22%5E%5E%3Chttp%3A%2F%2F' +# 'www.w3.org%2F2001%2FXMLSchema%23integer%3E', +# '%24data_world_param0%3D%22USA%22' +# ] +# ), +# ('sparql', 'notreallysparql', +# { +# '$aString': "USA", +# '$anInt': 10, +# '$aDecimal': 100.0, +# '$aBool': False, +# '$uUri': datadotworld.UriParam( +# 'https://example.com/something#something') +# }, +# [ +# '%24anInt%3D%2210%22%5E%5E%3Chttp%3A%2F%2F' +# 'www.w3.org%2F2001%2FXMLSchema%23integer%3E', +# '%24aDecimal%3D%22100.0%22%5E%5E%3Chttp%3A%2F%2F' +# 'www.w3.org%2F2001%2FXMLSchema%23decimal%3E', +# '%24aString%3D%22USA%22', +# '%24aBool%3D%22false%22%5E%5E%3Chttp%3A%2F%2F' +# 'www.w3.org%2F2001%2FXMLSchema%23boolean%3E', +# '%3Chttps%3A%2F%2Fexample.com%2Fsomething%23something%3E' +# ] +# ) +# ] +# +# @pytest.mark.parametrize("type,query,parameters,expected", +# parameterized_queries) +# def test_parameterized_queries(self, type, query, parameters, expected, +# dw, dataset_key, query_response_json): +# with responses.RequestsMock() as rsps: +# def request_callback(request): +# for value in expected: +# assert_that(request.url, contains_string(value), +# reason="Expected [[\n{}\n]] to contain " +# "[[\n{}\n]]".format(request.url, expected)) +# return(200, {}, json.dumps(query_response_json)) +# +# rsps.add_callback(rsps.GET, re.compile( +# r'https?://query\.data\.world/.*'), +# callback=request_callback, +# content_type="application/json", +# match_querystring=True) +# +# dw.query(dataset_key, query, query_type=type, +# parameters=parameters) +# +# def test_load_dataset(self, config, api_client, dw, dataset_key): +# dest_dir = path.join(config.cache_dir, 'agentid', 'datasetid', +# 'latest') +# assert_that(path.isdir(dest_dir), is_(False)) +# +# dataset = dw.load_dataset(dataset_key) +# +# assert_that(api_client.download_datapackage, +# called().times(1).with_args(equal_to(dataset_key), +# equal_to(dest_dir))) +# assert_that(dataset.raw_data, has_length(4)) +# +# def test_open_file_writer(self, dw, dataset_key): +# file_name = 'filename.ext' +# with responses.RequestsMock() as resp: +# resp.add(resp.PUT, re.compile('.*'), +# body='{}', status=200, content_type='application/json') +# w = dw.open_remote_file(dataset_key, file_name) +# assert_that(isinstance(w, RemoteFile)) +# try: +# w.open() +# finally: +# w.close() +# +# @pytest.mark.usefixtures('existing_dataset') +# def test_load_dataset_existing(self, api_client, dw, dataset_key): +# with warnings.catch_warnings(record=True) as w: +# dataset = dw.load_dataset(dataset_key) +# assert_that(w, has_length(0)) +# assert_that(api_client.download_datapackage, never(called())) +# assert_that(dataset.raw_data, has_length(3)) +# +# @pytest.mark.usefixtures('existing_dataset') +# def test_load_dataset_existing_expired(self, monkeypatch, api_client, dw, +# dataset_key): +# monkeypatch.setattr(os.path, 'getmtime', lambda _: 1468195199) +# with warnings.catch_warnings(record=True) as w: +# dataset = dw.load_dataset(dataset_key) +# assert_that(w, has_length(1)) +# assert_that(w[-1].category, equal_to(UserWarning)) +# +# assert_that(api_client.download_datapackage, never(called())) +# assert_that(dataset.raw_data, has_length(3)) +# +# @pytest.mark.usefixtures('existing_dataset') +# def test_load_dataset_existing_forced(self, api_client, dw, dataset_key): +# dataset = dw.load_dataset(dataset_key, force_update=True) +# +# assert_that(api_client.download_datapackage, +# called().times(1).with_args(equal_to(dataset_key), +# anything())) +# assert_that(dataset.raw_data, has_length(4)) +# +# @pytest.mark.usefixtures('existing_dataset') +# def test_load_dataset_forced_fallback(self, api_client, dw, dataset_key): +# when(api_client).download_datapackage(equal_to(dataset_key), +# anything()).raises(RestApiError) +# +# # Forced update +# with pytest.warns(UserWarning): +# dataset = dw.load_dataset(dataset_key, force_update=True) +# assert_that(api_client.download_datapackage, +# called().times(1).with_args(equal_to(dataset_key), +# anything())) +# assert_that(dataset.raw_data, has_length(3)) +# +# @pytest.mark.usefixtures('existing_dataset') +# def test_load_dataset_existing_expired_auto_update(self, monkeypatch, +# api_client, dw, +# dataset_key): +# monkeypatch.setattr(os.path, 'getmtime', lambda _: 1468195199) +# dataset = dw.load_dataset(dataset_key, auto_update=True) +# assert_that(api_client.download_datapackage, +# called().times(1).with_args(equal_to(dataset_key), +# anything())) +# assert_that(dataset.raw_data, has_length(4)) +# +# +# # Top-level methods +# +# @pytest.fixture() +# def dw_instances(monkeypatch): +# import datadotworld +# with Spy(DataDotWorld) as dw, Spy(DataDotWorld) as dw_alternative: +# dw.api_client = dw_alternative.api_client = Stub(RestApiClient) +# monkeypatch.setattr( +# datadotworld, '_get_instance', +# lambda profile: dw if profile == 'default' else dw_alternative) +# return {'default': dw, 'alternative': dw_alternative} +# +# +# @pytest.fixture(params=['default', 'alternative'], +# ids=['default', 'alternative']) +# def profile(request): +# return request.param +# +# +# def test_toplevel_load_dataset(dw_instances, profile): +# datadotworld.load_dataset('agentid/datasetid', profile=profile) +# assert_that(dw_instances[profile].load_dataset, +# called().times(1).with_args(equal_to('agentid/datasetid'), +# force_update=equal_to(False))) +# assert_that(dw_instances[profile].load_dataset, +# called().times(1).with_args(equal_to('agentid/datasetid'), +# auto_update=equal_to(False))) +# +# +# def test_toplevel_query(dw_instances, profile): +# datadotworld.query('agentid/datasetid', 'SELECT * FROM Tables', +# profile=profile) +# assert_that(dw_instances[profile].query, +# called().times(1).with_args(equal_to('agentid/datasetid'), +# equal_to('SELECT * FROM Tables'), +# query_type=equal_to('sql'))) +# +# +# def test_toplevel_api_client(dw_instances, profile): +# assert_that(datadotworld.api_client(), +# equal_to(dw_instances[profile].api_client)) diff --git a/tox.ini b/tox.ini index 1f05d23..a4f32ee 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,6 @@ envlist=py27,py34,py35,py36 deps=coverage commands= flake8 . \ - --exclude=datadotworld/client/_swagger/,./.tox/*,./.eggs/*,./build/* + --exclude=./.tox/*,./.eggs/*,./build/* coverage run setup.py test {posargs} - coverage report --omit=./.tox/* --fail-under=90 + coverage report --omit=./.tox/* --fail-under=75