From 8f8d7d42aeedddd5a7386101e8bb25bd3f99af3f Mon Sep 17 00:00:00 2001 From: Marcos Maceo Date: Tue, 12 Mar 2019 20:55:39 -0400 Subject: [PATCH] [restsharp] refs #86 Solving requested changes for PR --- .travis/install-linux.sh | 4 +- Makefile | 31 +- {pysky_api => skyapi}/.gitignore | 0 .../.openapi-generator-ignore | 0 .../.openapi-generator/VERSION | 0 {pysky_api => skyapi}/.travis.yml | 0 {pysky_api => skyapi}/README.md | 0 .../docs/Apiv1exploreraddressInputs.md | 0 .../docs/Apiv1exploreraddressOutputs.md | 0 .../docs/Apiv1exploreraddressStatus.md | 0 .../docs/Apiv1pendingTxsTransaction.md | 0 .../docs/Apiv1walletsEntries.md | 0 .../docs/Apiv1walletsMeta.md | 0 .../Apiv1wallettransactionHoursSelection.md | 0 .../docs/Apiv1wallettransactionTo.md | 0 .../docs/Apiv1wallettransactionWallet.md | 0 {pysky_api => skyapi}/docs/DefaultApi.md | 0 {pysky_api => skyapi}/docs/InlineObject.md | 0 .../docs/InlineResponse200.md | 0 .../docs/InlineResponse2001.md | 0 .../docs/InlineResponse2002.md | 0 .../docs/InlineResponse2003.md | 0 ...esponse2003UnconfirmedVerifyTransaction.md | 0 .../docs/InlineResponse2004.md | 0 .../docs/InlineResponse2005.md | 0 .../docs/InlineResponse2006.md | 0 .../docs/InlineResponse2007.md | 0 .../docs/InlineResponse2007Data.md | 0 .../docs/InlineResponseDefault.md | 0 {pysky_api => skyapi}/git_push.sh | 0 .../openapi_client/__init__.py | 0 .../openapi_client/api/__init__.py | 0 .../openapi_client/api/default_api.py | 0 .../openapi_client/api_client.py | 0 .../openapi_client/configuration.py | 0 .../openapi_client/models/__init__.py | 0 .../models/apiv1exploreraddress_inputs.py | 0 .../models/apiv1exploreraddress_outputs.py | 0 .../models/apiv1exploreraddress_status.py | 0 .../models/apiv1pending_txs_transaction.py | 0 .../models/apiv1wallets_entries.py | 0 .../models/apiv1wallets_meta.py | 0 .../apiv1wallettransaction_hours_selection.py | 0 .../models/apiv1wallettransaction_to.py | 0 .../models/apiv1wallettransaction_wallet.py | 0 .../openapi_client/models/inline_object.py | 0 .../models/inline_response200.py | 0 .../models/inline_response2001.py | 0 .../models/inline_response2002.py | 0 .../models/inline_response2003.py | 0 ...onse2003_unconfirmed_verify_transaction.py | 0 .../models/inline_response2004.py | 0 .../models/inline_response2005.py | 0 .../models/inline_response2006.py | 0 .../models/inline_response2007.py | 0 .../models/inline_response2007_data.py | 0 .../models/inline_response_default.py | 0 {pysky_api => skyapi}/openapi_client/rest.py | 0 {pysky_api => skyapi}/requirements.txt | 0 {pysky_api => skyapi}/setup.py | 0 {pysky_api => skyapi}/test-requirements.txt | 0 {pysky_api => skyapi}/test/__init__.py | 0 .../test/test_apiv1exploreraddress_inputs.py | 0 .../test/test_apiv1exploreraddress_outputs.py | 0 .../test/test_apiv1exploreraddress_status.py | 0 .../test/test_apiv1pending_txs_transaction.py | 0 .../test/test_apiv1wallets_entries.py | 0 .../test/test_apiv1wallets_meta.py | 0 ..._apiv1wallettransaction_hours_selection.py | 0 .../test/test_apiv1wallettransaction_to.py | 0 .../test_apiv1wallettransaction_wallet.py | 0 .../test/test_default_api.py | 0 .../test/test_inline_object.py | 0 .../test/test_inline_response200.py | 0 .../test/test_inline_response2001.py | 0 .../test/test_inline_response2002.py | 0 .../test/test_inline_response2003.py | 0 ...onse2003_unconfirmed_verify_transaction.py | 0 .../test/test_inline_response2004.py | 0 .../test/test_inline_response2005.py | 0 .../test/test_inline_response2006.py | 0 .../test/test_inline_response2007.py | 0 .../test/test_inline_response2007_data.py | 0 .../test/test_inline_response_default.py | 0 {pysky_api => skyapi}/tox.ini | 0 skycoin/restapi/__init__.py | 27 - skycoin/restapi/api/__init__.py | 6 - skycoin/restapi/api/default_api.py | 488 -------------- skycoin/restapi/api_client.py | 620 ------------------ skycoin/restapi/configuration.py | 246 ------- skycoin/restapi/models/__init__.py | 20 - skycoin/restapi/models/build_info.py | 169 ----- skycoin/restapi/models/inline_response_200.py | 113 ---- skycoin/restapi/models/inline_response_422.py | 163 ----- .../restapi/models/inline_response_default.py | 137 ---- skycoin/restapi/rest.py | 322 --------- 96 files changed, 15 insertions(+), 2331 deletions(-) rename {pysky_api => skyapi}/.gitignore (100%) rename {pysky_api => skyapi}/.openapi-generator-ignore (100%) rename {pysky_api => skyapi}/.openapi-generator/VERSION (100%) rename {pysky_api => skyapi}/.travis.yml (100%) rename {pysky_api => skyapi}/README.md (100%) rename {pysky_api => skyapi}/docs/Apiv1exploreraddressInputs.md (100%) rename {pysky_api => skyapi}/docs/Apiv1exploreraddressOutputs.md (100%) rename {pysky_api => skyapi}/docs/Apiv1exploreraddressStatus.md (100%) rename {pysky_api => skyapi}/docs/Apiv1pendingTxsTransaction.md (100%) rename {pysky_api => skyapi}/docs/Apiv1walletsEntries.md (100%) rename {pysky_api => skyapi}/docs/Apiv1walletsMeta.md (100%) rename {pysky_api => skyapi}/docs/Apiv1wallettransactionHoursSelection.md (100%) rename {pysky_api => skyapi}/docs/Apiv1wallettransactionTo.md (100%) rename {pysky_api => skyapi}/docs/Apiv1wallettransactionWallet.md (100%) rename {pysky_api => skyapi}/docs/DefaultApi.md (100%) rename {pysky_api => skyapi}/docs/InlineObject.md (100%) rename {pysky_api => skyapi}/docs/InlineResponse200.md (100%) rename {pysky_api => skyapi}/docs/InlineResponse2001.md (100%) rename {pysky_api => skyapi}/docs/InlineResponse2002.md (100%) rename {pysky_api => skyapi}/docs/InlineResponse2003.md (100%) rename {pysky_api => skyapi}/docs/InlineResponse2003UnconfirmedVerifyTransaction.md (100%) rename {pysky_api => skyapi}/docs/InlineResponse2004.md (100%) rename {pysky_api => skyapi}/docs/InlineResponse2005.md (100%) rename {pysky_api => skyapi}/docs/InlineResponse2006.md (100%) rename {pysky_api => skyapi}/docs/InlineResponse2007.md (100%) rename {pysky_api => skyapi}/docs/InlineResponse2007Data.md (100%) rename {pysky_api => skyapi}/docs/InlineResponseDefault.md (100%) rename {pysky_api => skyapi}/git_push.sh (100%) rename {pysky_api => skyapi}/openapi_client/__init__.py (100%) rename {pysky_api => skyapi}/openapi_client/api/__init__.py (100%) rename {pysky_api => skyapi}/openapi_client/api/default_api.py (100%) rename {pysky_api => skyapi}/openapi_client/api_client.py (100%) rename {pysky_api => skyapi}/openapi_client/configuration.py (100%) rename {pysky_api => skyapi}/openapi_client/models/__init__.py (100%) rename {pysky_api => skyapi}/openapi_client/models/apiv1exploreraddress_inputs.py (100%) rename {pysky_api => skyapi}/openapi_client/models/apiv1exploreraddress_outputs.py (100%) rename {pysky_api => skyapi}/openapi_client/models/apiv1exploreraddress_status.py (100%) rename {pysky_api => skyapi}/openapi_client/models/apiv1pending_txs_transaction.py (100%) rename {pysky_api => skyapi}/openapi_client/models/apiv1wallets_entries.py (100%) rename {pysky_api => skyapi}/openapi_client/models/apiv1wallets_meta.py (100%) rename {pysky_api => skyapi}/openapi_client/models/apiv1wallettransaction_hours_selection.py (100%) rename {pysky_api => skyapi}/openapi_client/models/apiv1wallettransaction_to.py (100%) rename {pysky_api => skyapi}/openapi_client/models/apiv1wallettransaction_wallet.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_object.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_response200.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_response2001.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_response2002.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_response2003.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_response2003_unconfirmed_verify_transaction.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_response2004.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_response2005.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_response2006.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_response2007.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_response2007_data.py (100%) rename {pysky_api => skyapi}/openapi_client/models/inline_response_default.py (100%) rename {pysky_api => skyapi}/openapi_client/rest.py (100%) rename {pysky_api => skyapi}/requirements.txt (100%) rename {pysky_api => skyapi}/setup.py (100%) rename {pysky_api => skyapi}/test-requirements.txt (100%) rename {pysky_api => skyapi}/test/__init__.py (100%) rename {pysky_api => skyapi}/test/test_apiv1exploreraddress_inputs.py (100%) rename {pysky_api => skyapi}/test/test_apiv1exploreraddress_outputs.py (100%) rename {pysky_api => skyapi}/test/test_apiv1exploreraddress_status.py (100%) rename {pysky_api => skyapi}/test/test_apiv1pending_txs_transaction.py (100%) rename {pysky_api => skyapi}/test/test_apiv1wallets_entries.py (100%) rename {pysky_api => skyapi}/test/test_apiv1wallets_meta.py (100%) rename {pysky_api => skyapi}/test/test_apiv1wallettransaction_hours_selection.py (100%) rename {pysky_api => skyapi}/test/test_apiv1wallettransaction_to.py (100%) rename {pysky_api => skyapi}/test/test_apiv1wallettransaction_wallet.py (100%) rename {pysky_api => skyapi}/test/test_default_api.py (100%) rename {pysky_api => skyapi}/test/test_inline_object.py (100%) rename {pysky_api => skyapi}/test/test_inline_response200.py (100%) rename {pysky_api => skyapi}/test/test_inline_response2001.py (100%) rename {pysky_api => skyapi}/test/test_inline_response2002.py (100%) rename {pysky_api => skyapi}/test/test_inline_response2003.py (100%) rename {pysky_api => skyapi}/test/test_inline_response2003_unconfirmed_verify_transaction.py (100%) rename {pysky_api => skyapi}/test/test_inline_response2004.py (100%) rename {pysky_api => skyapi}/test/test_inline_response2005.py (100%) rename {pysky_api => skyapi}/test/test_inline_response2006.py (100%) rename {pysky_api => skyapi}/test/test_inline_response2007.py (100%) rename {pysky_api => skyapi}/test/test_inline_response2007_data.py (100%) rename {pysky_api => skyapi}/test/test_inline_response_default.py (100%) rename {pysky_api => skyapi}/tox.ini (100%) delete mode 100644 skycoin/restapi/__init__.py delete mode 100644 skycoin/restapi/api/__init__.py delete mode 100644 skycoin/restapi/api/default_api.py delete mode 100644 skycoin/restapi/api_client.py delete mode 100644 skycoin/restapi/configuration.py delete mode 100644 skycoin/restapi/models/__init__.py delete mode 100644 skycoin/restapi/models/build_info.py delete mode 100644 skycoin/restapi/models/inline_response_200.py delete mode 100644 skycoin/restapi/models/inline_response_422.py delete mode 100644 skycoin/restapi/models/inline_response_default.py delete mode 100644 skycoin/restapi/rest.py diff --git a/.travis/install-linux.sh b/.travis/install-linux.sh index dbbd0105..7ddf1a5d 100644 --- a/.travis/install-linux.sh +++ b/.travis/install-linux.sh @@ -18,8 +18,8 @@ chmod +x "$HOME/bin/gimme" # Install Python libraries $PIP install --upgrade pip setuptools tox-travis $PIP install -r "$REPO_ROOT/requirements.dev.txt" -$PIP install -r "$REPO_ROOT/pysky_api/requirements.txt" -$PIP install -r "$REPO_ROOT/pysky_api/test-requirements.txt" +$PIP install -r "$REPO_ROOT/skyapi/requirements.txt" +$PIP install -r "$REPO_ROOT/skyapi/test-requirements.txt" # Compile SWIG mkdir swig_build && \ diff --git a/Makefile b/Makefile index d477d260..e9b17f22 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ .DEFAULT_GOAL := help -.PHONY: configure build-libc build-swig develop build-libc-swig build build-pysky_api +.PHONY: configure build-libc build-swig develop build-libc-swig build .PHONY: test test-ci help # Compilation output .ONESHELL: SHELL := /bin/bash -PYTHON_BIN = python +PYTHON = python PWD = $(shell pwd) GOPATH_DIR = $(PWD)/gopath SKYCOIN_DIR = gopath/src/github.com/skycoin/skycoin @@ -25,7 +25,7 @@ SRC_FILES = $(shell find $(SKYCOIN_DIR)/src -type f -name "*.go") SWIG_FILES = $(shell find $(LIBSWIG_DIR) -type f -name "*.i") HEADER_FILES = $(shell find $(SKYCOIN_DIR)/include -type f -name "*.h") -PYTHON_CLIENT_DIR = pysky_api +PYTHON_CLIENT_DIR = skyapi ifeq ($(shell uname -s),Linux) TEMP_DIR = tmp @@ -38,11 +38,6 @@ configure: ## Configure build environment mkdir -p $(BUILDLIBC_DIR) $(BIN_DIR) $(INCLUDE_DIR) mkdir -p $(DIST_DIR) -generate-python-Client: ## Configure build environment - mkdir -p $(BUILD_DIR)/usr/tmp $(BUILD_DIR)/usr/lib $(BUILD_DIR)/usr/include - mkdir -p $(BUILDLIBC_DIR) $(BIN_DIR) $(INCLUDE_DIR) - mkdir -p $(DIST_DIR) - $(BUILDLIBC_DIR)/libskycoin.a: $(LIB_FILES) $(SRC_FILES) $(HEADER_FILES) rm -f $(BUILDLIBC_DIR)/libskycoin.a GOPATH="$(GOPATH_DIR)" make -C $(SKYCOIN_DIR) build-libc-static @@ -72,30 +67,30 @@ build-swig: ## Generate Python C module from SWIG interfaces swig -python -Iswig/include -I$(INCLUDE_DIR) -outdir ./skycoin/ -o swig/pyskycoin_wrap.c $(LIBSWIG_DIR)/pyskycoin.i develop: ## Install PySkycoin for development - $(PYTHON_BIN) setup.py develop - (cd $(PYTHON_CLIENT_DIR) && $(PYTHON_BIN) setup.py develop) + $(PYTHON) setup.py develop + (cd $(PYTHON_CLIENT_DIR) && $(PYTHON) setup.py develop) build-libc-swig: build-libc build-swig build: build-libc-swig ## Build PySkycoin Python package - $(PYTHON_BIN) setup.py build - (cd $(PYTHON_CLIENT_DIR) && $(PYTHON_BIN) setup.py build) + $(PYTHON) setup.py build + (cd $(PYTHON_CLIENT_DIR) && $(PYTHON) setup.py build) test-ci: ## Run tests on (Travis) CI build tox (cd $(PYTHON_CLIENT_DIR) && tox) test: build-libc build-swig develop ## Run project test suite - $(PYTHON_BIN) setup.py test - (cd $(PYTHON_CLIENT_DIR) && $(PYTHON_BIN) setup.py test) + $(PYTHON) setup.py test + (cd $(PYTHON_CLIENT_DIR) && $(PYTHON) setup.py test) sdist: ## Create source distribution archive - $(PYTHON_BIN) setup.py sdist --formats=gztar - (cd $(PYTHON_CLIENT_DIR) && $(PYTHON_BIN) setup.py sdist --formats=gztar) + $(PYTHON) setup.py sdist --formats=gztar + (cd $(PYTHON_CLIENT_DIR) && $(PYTHON) setup.py sdist --formats=gztar) bdist_wheel: ## Create architecture-specific binary wheel distribution archive - $(PYTHON_BIN) setup.py bdist_wheel - (cd $(PYTHON_CLIENT_DIR) && $(PYTHON_BIN) setup.py bdist_wheel) + $(PYTHON) setup.py bdist_wheel + (cd $(PYTHON_CLIENT_DIR) && $(PYTHON) setup.py bdist_wheel) # FIXME: After libskycoin 32-bits binaries add bdist_manylinux_i686 bdist_manylinux: bdist_manylinux_amd64 ## Create multilinux binary wheel distribution archives diff --git a/pysky_api/.gitignore b/skyapi/.gitignore similarity index 100% rename from pysky_api/.gitignore rename to skyapi/.gitignore diff --git a/pysky_api/.openapi-generator-ignore b/skyapi/.openapi-generator-ignore similarity index 100% rename from pysky_api/.openapi-generator-ignore rename to skyapi/.openapi-generator-ignore diff --git a/pysky_api/.openapi-generator/VERSION b/skyapi/.openapi-generator/VERSION similarity index 100% rename from pysky_api/.openapi-generator/VERSION rename to skyapi/.openapi-generator/VERSION diff --git a/pysky_api/.travis.yml b/skyapi/.travis.yml similarity index 100% rename from pysky_api/.travis.yml rename to skyapi/.travis.yml diff --git a/pysky_api/README.md b/skyapi/README.md similarity index 100% rename from pysky_api/README.md rename to skyapi/README.md diff --git a/pysky_api/docs/Apiv1exploreraddressInputs.md b/skyapi/docs/Apiv1exploreraddressInputs.md similarity index 100% rename from pysky_api/docs/Apiv1exploreraddressInputs.md rename to skyapi/docs/Apiv1exploreraddressInputs.md diff --git a/pysky_api/docs/Apiv1exploreraddressOutputs.md b/skyapi/docs/Apiv1exploreraddressOutputs.md similarity index 100% rename from pysky_api/docs/Apiv1exploreraddressOutputs.md rename to skyapi/docs/Apiv1exploreraddressOutputs.md diff --git a/pysky_api/docs/Apiv1exploreraddressStatus.md b/skyapi/docs/Apiv1exploreraddressStatus.md similarity index 100% rename from pysky_api/docs/Apiv1exploreraddressStatus.md rename to skyapi/docs/Apiv1exploreraddressStatus.md diff --git a/pysky_api/docs/Apiv1pendingTxsTransaction.md b/skyapi/docs/Apiv1pendingTxsTransaction.md similarity index 100% rename from pysky_api/docs/Apiv1pendingTxsTransaction.md rename to skyapi/docs/Apiv1pendingTxsTransaction.md diff --git a/pysky_api/docs/Apiv1walletsEntries.md b/skyapi/docs/Apiv1walletsEntries.md similarity index 100% rename from pysky_api/docs/Apiv1walletsEntries.md rename to skyapi/docs/Apiv1walletsEntries.md diff --git a/pysky_api/docs/Apiv1walletsMeta.md b/skyapi/docs/Apiv1walletsMeta.md similarity index 100% rename from pysky_api/docs/Apiv1walletsMeta.md rename to skyapi/docs/Apiv1walletsMeta.md diff --git a/pysky_api/docs/Apiv1wallettransactionHoursSelection.md b/skyapi/docs/Apiv1wallettransactionHoursSelection.md similarity index 100% rename from pysky_api/docs/Apiv1wallettransactionHoursSelection.md rename to skyapi/docs/Apiv1wallettransactionHoursSelection.md diff --git a/pysky_api/docs/Apiv1wallettransactionTo.md b/skyapi/docs/Apiv1wallettransactionTo.md similarity index 100% rename from pysky_api/docs/Apiv1wallettransactionTo.md rename to skyapi/docs/Apiv1wallettransactionTo.md diff --git a/pysky_api/docs/Apiv1wallettransactionWallet.md b/skyapi/docs/Apiv1wallettransactionWallet.md similarity index 100% rename from pysky_api/docs/Apiv1wallettransactionWallet.md rename to skyapi/docs/Apiv1wallettransactionWallet.md diff --git a/pysky_api/docs/DefaultApi.md b/skyapi/docs/DefaultApi.md similarity index 100% rename from pysky_api/docs/DefaultApi.md rename to skyapi/docs/DefaultApi.md diff --git a/pysky_api/docs/InlineObject.md b/skyapi/docs/InlineObject.md similarity index 100% rename from pysky_api/docs/InlineObject.md rename to skyapi/docs/InlineObject.md diff --git a/pysky_api/docs/InlineResponse200.md b/skyapi/docs/InlineResponse200.md similarity index 100% rename from pysky_api/docs/InlineResponse200.md rename to skyapi/docs/InlineResponse200.md diff --git a/pysky_api/docs/InlineResponse2001.md b/skyapi/docs/InlineResponse2001.md similarity index 100% rename from pysky_api/docs/InlineResponse2001.md rename to skyapi/docs/InlineResponse2001.md diff --git a/pysky_api/docs/InlineResponse2002.md b/skyapi/docs/InlineResponse2002.md similarity index 100% rename from pysky_api/docs/InlineResponse2002.md rename to skyapi/docs/InlineResponse2002.md diff --git a/pysky_api/docs/InlineResponse2003.md b/skyapi/docs/InlineResponse2003.md similarity index 100% rename from pysky_api/docs/InlineResponse2003.md rename to skyapi/docs/InlineResponse2003.md diff --git a/pysky_api/docs/InlineResponse2003UnconfirmedVerifyTransaction.md b/skyapi/docs/InlineResponse2003UnconfirmedVerifyTransaction.md similarity index 100% rename from pysky_api/docs/InlineResponse2003UnconfirmedVerifyTransaction.md rename to skyapi/docs/InlineResponse2003UnconfirmedVerifyTransaction.md diff --git a/pysky_api/docs/InlineResponse2004.md b/skyapi/docs/InlineResponse2004.md similarity index 100% rename from pysky_api/docs/InlineResponse2004.md rename to skyapi/docs/InlineResponse2004.md diff --git a/pysky_api/docs/InlineResponse2005.md b/skyapi/docs/InlineResponse2005.md similarity index 100% rename from pysky_api/docs/InlineResponse2005.md rename to skyapi/docs/InlineResponse2005.md diff --git a/pysky_api/docs/InlineResponse2006.md b/skyapi/docs/InlineResponse2006.md similarity index 100% rename from pysky_api/docs/InlineResponse2006.md rename to skyapi/docs/InlineResponse2006.md diff --git a/pysky_api/docs/InlineResponse2007.md b/skyapi/docs/InlineResponse2007.md similarity index 100% rename from pysky_api/docs/InlineResponse2007.md rename to skyapi/docs/InlineResponse2007.md diff --git a/pysky_api/docs/InlineResponse2007Data.md b/skyapi/docs/InlineResponse2007Data.md similarity index 100% rename from pysky_api/docs/InlineResponse2007Data.md rename to skyapi/docs/InlineResponse2007Data.md diff --git a/pysky_api/docs/InlineResponseDefault.md b/skyapi/docs/InlineResponseDefault.md similarity index 100% rename from pysky_api/docs/InlineResponseDefault.md rename to skyapi/docs/InlineResponseDefault.md diff --git a/pysky_api/git_push.sh b/skyapi/git_push.sh similarity index 100% rename from pysky_api/git_push.sh rename to skyapi/git_push.sh diff --git a/pysky_api/openapi_client/__init__.py b/skyapi/openapi_client/__init__.py similarity index 100% rename from pysky_api/openapi_client/__init__.py rename to skyapi/openapi_client/__init__.py diff --git a/pysky_api/openapi_client/api/__init__.py b/skyapi/openapi_client/api/__init__.py similarity index 100% rename from pysky_api/openapi_client/api/__init__.py rename to skyapi/openapi_client/api/__init__.py diff --git a/pysky_api/openapi_client/api/default_api.py b/skyapi/openapi_client/api/default_api.py similarity index 100% rename from pysky_api/openapi_client/api/default_api.py rename to skyapi/openapi_client/api/default_api.py diff --git a/pysky_api/openapi_client/api_client.py b/skyapi/openapi_client/api_client.py similarity index 100% rename from pysky_api/openapi_client/api_client.py rename to skyapi/openapi_client/api_client.py diff --git a/pysky_api/openapi_client/configuration.py b/skyapi/openapi_client/configuration.py similarity index 100% rename from pysky_api/openapi_client/configuration.py rename to skyapi/openapi_client/configuration.py diff --git a/pysky_api/openapi_client/models/__init__.py b/skyapi/openapi_client/models/__init__.py similarity index 100% rename from pysky_api/openapi_client/models/__init__.py rename to skyapi/openapi_client/models/__init__.py diff --git a/pysky_api/openapi_client/models/apiv1exploreraddress_inputs.py b/skyapi/openapi_client/models/apiv1exploreraddress_inputs.py similarity index 100% rename from pysky_api/openapi_client/models/apiv1exploreraddress_inputs.py rename to skyapi/openapi_client/models/apiv1exploreraddress_inputs.py diff --git a/pysky_api/openapi_client/models/apiv1exploreraddress_outputs.py b/skyapi/openapi_client/models/apiv1exploreraddress_outputs.py similarity index 100% rename from pysky_api/openapi_client/models/apiv1exploreraddress_outputs.py rename to skyapi/openapi_client/models/apiv1exploreraddress_outputs.py diff --git a/pysky_api/openapi_client/models/apiv1exploreraddress_status.py b/skyapi/openapi_client/models/apiv1exploreraddress_status.py similarity index 100% rename from pysky_api/openapi_client/models/apiv1exploreraddress_status.py rename to skyapi/openapi_client/models/apiv1exploreraddress_status.py diff --git a/pysky_api/openapi_client/models/apiv1pending_txs_transaction.py b/skyapi/openapi_client/models/apiv1pending_txs_transaction.py similarity index 100% rename from pysky_api/openapi_client/models/apiv1pending_txs_transaction.py rename to skyapi/openapi_client/models/apiv1pending_txs_transaction.py diff --git a/pysky_api/openapi_client/models/apiv1wallets_entries.py b/skyapi/openapi_client/models/apiv1wallets_entries.py similarity index 100% rename from pysky_api/openapi_client/models/apiv1wallets_entries.py rename to skyapi/openapi_client/models/apiv1wallets_entries.py diff --git a/pysky_api/openapi_client/models/apiv1wallets_meta.py b/skyapi/openapi_client/models/apiv1wallets_meta.py similarity index 100% rename from pysky_api/openapi_client/models/apiv1wallets_meta.py rename to skyapi/openapi_client/models/apiv1wallets_meta.py diff --git a/pysky_api/openapi_client/models/apiv1wallettransaction_hours_selection.py b/skyapi/openapi_client/models/apiv1wallettransaction_hours_selection.py similarity index 100% rename from pysky_api/openapi_client/models/apiv1wallettransaction_hours_selection.py rename to skyapi/openapi_client/models/apiv1wallettransaction_hours_selection.py diff --git a/pysky_api/openapi_client/models/apiv1wallettransaction_to.py b/skyapi/openapi_client/models/apiv1wallettransaction_to.py similarity index 100% rename from pysky_api/openapi_client/models/apiv1wallettransaction_to.py rename to skyapi/openapi_client/models/apiv1wallettransaction_to.py diff --git a/pysky_api/openapi_client/models/apiv1wallettransaction_wallet.py b/skyapi/openapi_client/models/apiv1wallettransaction_wallet.py similarity index 100% rename from pysky_api/openapi_client/models/apiv1wallettransaction_wallet.py rename to skyapi/openapi_client/models/apiv1wallettransaction_wallet.py diff --git a/pysky_api/openapi_client/models/inline_object.py b/skyapi/openapi_client/models/inline_object.py similarity index 100% rename from pysky_api/openapi_client/models/inline_object.py rename to skyapi/openapi_client/models/inline_object.py diff --git a/pysky_api/openapi_client/models/inline_response200.py b/skyapi/openapi_client/models/inline_response200.py similarity index 100% rename from pysky_api/openapi_client/models/inline_response200.py rename to skyapi/openapi_client/models/inline_response200.py diff --git a/pysky_api/openapi_client/models/inline_response2001.py b/skyapi/openapi_client/models/inline_response2001.py similarity index 100% rename from pysky_api/openapi_client/models/inline_response2001.py rename to skyapi/openapi_client/models/inline_response2001.py diff --git a/pysky_api/openapi_client/models/inline_response2002.py b/skyapi/openapi_client/models/inline_response2002.py similarity index 100% rename from pysky_api/openapi_client/models/inline_response2002.py rename to skyapi/openapi_client/models/inline_response2002.py diff --git a/pysky_api/openapi_client/models/inline_response2003.py b/skyapi/openapi_client/models/inline_response2003.py similarity index 100% rename from pysky_api/openapi_client/models/inline_response2003.py rename to skyapi/openapi_client/models/inline_response2003.py diff --git a/pysky_api/openapi_client/models/inline_response2003_unconfirmed_verify_transaction.py b/skyapi/openapi_client/models/inline_response2003_unconfirmed_verify_transaction.py similarity index 100% rename from pysky_api/openapi_client/models/inline_response2003_unconfirmed_verify_transaction.py rename to skyapi/openapi_client/models/inline_response2003_unconfirmed_verify_transaction.py diff --git a/pysky_api/openapi_client/models/inline_response2004.py b/skyapi/openapi_client/models/inline_response2004.py similarity index 100% rename from pysky_api/openapi_client/models/inline_response2004.py rename to skyapi/openapi_client/models/inline_response2004.py diff --git a/pysky_api/openapi_client/models/inline_response2005.py b/skyapi/openapi_client/models/inline_response2005.py similarity index 100% rename from pysky_api/openapi_client/models/inline_response2005.py rename to skyapi/openapi_client/models/inline_response2005.py diff --git a/pysky_api/openapi_client/models/inline_response2006.py b/skyapi/openapi_client/models/inline_response2006.py similarity index 100% rename from pysky_api/openapi_client/models/inline_response2006.py rename to skyapi/openapi_client/models/inline_response2006.py diff --git a/pysky_api/openapi_client/models/inline_response2007.py b/skyapi/openapi_client/models/inline_response2007.py similarity index 100% rename from pysky_api/openapi_client/models/inline_response2007.py rename to skyapi/openapi_client/models/inline_response2007.py diff --git a/pysky_api/openapi_client/models/inline_response2007_data.py b/skyapi/openapi_client/models/inline_response2007_data.py similarity index 100% rename from pysky_api/openapi_client/models/inline_response2007_data.py rename to skyapi/openapi_client/models/inline_response2007_data.py diff --git a/pysky_api/openapi_client/models/inline_response_default.py b/skyapi/openapi_client/models/inline_response_default.py similarity index 100% rename from pysky_api/openapi_client/models/inline_response_default.py rename to skyapi/openapi_client/models/inline_response_default.py diff --git a/pysky_api/openapi_client/rest.py b/skyapi/openapi_client/rest.py similarity index 100% rename from pysky_api/openapi_client/rest.py rename to skyapi/openapi_client/rest.py diff --git a/pysky_api/requirements.txt b/skyapi/requirements.txt similarity index 100% rename from pysky_api/requirements.txt rename to skyapi/requirements.txt diff --git a/pysky_api/setup.py b/skyapi/setup.py similarity index 100% rename from pysky_api/setup.py rename to skyapi/setup.py diff --git a/pysky_api/test-requirements.txt b/skyapi/test-requirements.txt similarity index 100% rename from pysky_api/test-requirements.txt rename to skyapi/test-requirements.txt diff --git a/pysky_api/test/__init__.py b/skyapi/test/__init__.py similarity index 100% rename from pysky_api/test/__init__.py rename to skyapi/test/__init__.py diff --git a/pysky_api/test/test_apiv1exploreraddress_inputs.py b/skyapi/test/test_apiv1exploreraddress_inputs.py similarity index 100% rename from pysky_api/test/test_apiv1exploreraddress_inputs.py rename to skyapi/test/test_apiv1exploreraddress_inputs.py diff --git a/pysky_api/test/test_apiv1exploreraddress_outputs.py b/skyapi/test/test_apiv1exploreraddress_outputs.py similarity index 100% rename from pysky_api/test/test_apiv1exploreraddress_outputs.py rename to skyapi/test/test_apiv1exploreraddress_outputs.py diff --git a/pysky_api/test/test_apiv1exploreraddress_status.py b/skyapi/test/test_apiv1exploreraddress_status.py similarity index 100% rename from pysky_api/test/test_apiv1exploreraddress_status.py rename to skyapi/test/test_apiv1exploreraddress_status.py diff --git a/pysky_api/test/test_apiv1pending_txs_transaction.py b/skyapi/test/test_apiv1pending_txs_transaction.py similarity index 100% rename from pysky_api/test/test_apiv1pending_txs_transaction.py rename to skyapi/test/test_apiv1pending_txs_transaction.py diff --git a/pysky_api/test/test_apiv1wallets_entries.py b/skyapi/test/test_apiv1wallets_entries.py similarity index 100% rename from pysky_api/test/test_apiv1wallets_entries.py rename to skyapi/test/test_apiv1wallets_entries.py diff --git a/pysky_api/test/test_apiv1wallets_meta.py b/skyapi/test/test_apiv1wallets_meta.py similarity index 100% rename from pysky_api/test/test_apiv1wallets_meta.py rename to skyapi/test/test_apiv1wallets_meta.py diff --git a/pysky_api/test/test_apiv1wallettransaction_hours_selection.py b/skyapi/test/test_apiv1wallettransaction_hours_selection.py similarity index 100% rename from pysky_api/test/test_apiv1wallettransaction_hours_selection.py rename to skyapi/test/test_apiv1wallettransaction_hours_selection.py diff --git a/pysky_api/test/test_apiv1wallettransaction_to.py b/skyapi/test/test_apiv1wallettransaction_to.py similarity index 100% rename from pysky_api/test/test_apiv1wallettransaction_to.py rename to skyapi/test/test_apiv1wallettransaction_to.py diff --git a/pysky_api/test/test_apiv1wallettransaction_wallet.py b/skyapi/test/test_apiv1wallettransaction_wallet.py similarity index 100% rename from pysky_api/test/test_apiv1wallettransaction_wallet.py rename to skyapi/test/test_apiv1wallettransaction_wallet.py diff --git a/pysky_api/test/test_default_api.py b/skyapi/test/test_default_api.py similarity index 100% rename from pysky_api/test/test_default_api.py rename to skyapi/test/test_default_api.py diff --git a/pysky_api/test/test_inline_object.py b/skyapi/test/test_inline_object.py similarity index 100% rename from pysky_api/test/test_inline_object.py rename to skyapi/test/test_inline_object.py diff --git a/pysky_api/test/test_inline_response200.py b/skyapi/test/test_inline_response200.py similarity index 100% rename from pysky_api/test/test_inline_response200.py rename to skyapi/test/test_inline_response200.py diff --git a/pysky_api/test/test_inline_response2001.py b/skyapi/test/test_inline_response2001.py similarity index 100% rename from pysky_api/test/test_inline_response2001.py rename to skyapi/test/test_inline_response2001.py diff --git a/pysky_api/test/test_inline_response2002.py b/skyapi/test/test_inline_response2002.py similarity index 100% rename from pysky_api/test/test_inline_response2002.py rename to skyapi/test/test_inline_response2002.py diff --git a/pysky_api/test/test_inline_response2003.py b/skyapi/test/test_inline_response2003.py similarity index 100% rename from pysky_api/test/test_inline_response2003.py rename to skyapi/test/test_inline_response2003.py diff --git a/pysky_api/test/test_inline_response2003_unconfirmed_verify_transaction.py b/skyapi/test/test_inline_response2003_unconfirmed_verify_transaction.py similarity index 100% rename from pysky_api/test/test_inline_response2003_unconfirmed_verify_transaction.py rename to skyapi/test/test_inline_response2003_unconfirmed_verify_transaction.py diff --git a/pysky_api/test/test_inline_response2004.py b/skyapi/test/test_inline_response2004.py similarity index 100% rename from pysky_api/test/test_inline_response2004.py rename to skyapi/test/test_inline_response2004.py diff --git a/pysky_api/test/test_inline_response2005.py b/skyapi/test/test_inline_response2005.py similarity index 100% rename from pysky_api/test/test_inline_response2005.py rename to skyapi/test/test_inline_response2005.py diff --git a/pysky_api/test/test_inline_response2006.py b/skyapi/test/test_inline_response2006.py similarity index 100% rename from pysky_api/test/test_inline_response2006.py rename to skyapi/test/test_inline_response2006.py diff --git a/pysky_api/test/test_inline_response2007.py b/skyapi/test/test_inline_response2007.py similarity index 100% rename from pysky_api/test/test_inline_response2007.py rename to skyapi/test/test_inline_response2007.py diff --git a/pysky_api/test/test_inline_response2007_data.py b/skyapi/test/test_inline_response2007_data.py similarity index 100% rename from pysky_api/test/test_inline_response2007_data.py rename to skyapi/test/test_inline_response2007_data.py diff --git a/pysky_api/test/test_inline_response_default.py b/skyapi/test/test_inline_response_default.py similarity index 100% rename from pysky_api/test/test_inline_response_default.py rename to skyapi/test/test_inline_response_default.py diff --git a/pysky_api/tox.ini b/skyapi/tox.ini similarity index 100% rename from pysky_api/tox.ini rename to skyapi/tox.ini diff --git a/skycoin/restapi/__init__.py b/skycoin/restapi/__init__.py deleted file mode 100644 index 3f02b925..00000000 --- a/skycoin/restapi/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding: utf-8 - -# flake8: noqa - -""" - - No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: contact@skycoin.net - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -# import apis into sdk package -from swagger_client.api.default_api import DefaultApi - -# import ApiClient -from swagger_client.api_client import ApiClient -from swagger_client.configuration import Configuration -# import models into sdk package -from swagger_client.models.build_info import BuildInfo -from swagger_client.models.inline_response_200 import InlineResponse200 -from swagger_client.models.inline_response_422 import InlineResponse422 -from swagger_client.models.inline_response_default import InlineResponseDefault diff --git a/skycoin/restapi/api/__init__.py b/skycoin/restapi/api/__init__.py deleted file mode 100644 index 447bb1c3..00000000 --- a/skycoin/restapi/api/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from __future__ import absolute_import - -# flake8: noqa - -# import apis into api package -from swagger_client.api.default_api import DefaultApi diff --git a/skycoin/restapi/api/default_api.py b/skycoin/restapi/api/default_api.py deleted file mode 100644 index 98cea980..00000000 --- a/skycoin/restapi/api/default_api.py +++ /dev/null @@ -1,488 +0,0 @@ -# coding: utf-8 - -""" - - No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: contact@skycoin.net - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import re # noqa: F401 - -# python 2 and python 3 compatibility library -import six - -from swagger_client.api_client import ApiClient - - -class DefaultApi(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): - if api_client is None: - api_client = ApiClient() - self.api_client = api_client - - def coin_supply(self, **kwargs): # noqa: E501 - """coin_supply # noqa: E501 - - coinSupplyHandler returns coin distribution supply stats # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True - >>> thread = api.coin_supply(async=True) - >>> result = thread.get() - - :param async bool - :return: None - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async'): - return self.coin_supply_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.coin_supply_with_http_info(**kwargs) # noqa: E501 - return data - - def coin_supply_with_http_info(self, **kwargs): # noqa: E501 - """coin_supply # noqa: E501 - - coinSupplyHandler returns coin distribution supply stats # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True - >>> thread = api.coin_supply_with_http_info(async=True) - >>> result = thread.get() - - :param async bool - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = [] # noqa: E501 - all_params.append('async') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in six.iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method coin_supply" % 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']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 - - # Authentication setting - auth_settings = ['csrfAuth'] # noqa: E501 - - return self.api_client.call_api( - '/api/v1/coinSupply', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async=params.get('async'), - _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 csrf_token(self, **kwargs): # noqa: E501 - """Creates a new CSRF token. Previous CSRF tokens are invalidated by this call. # noqa: E501 - - Response -> CSRF token to use in POST requests # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True - >>> thread = api.csrf_token(async=True) - >>> result = thread.get() - - :param async bool - :return: InlineResponse200 - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async'): - return self.csrf_token_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.csrf_token_with_http_info(**kwargs) # noqa: E501 - return data - - def csrf_token_with_http_info(self, **kwargs): # noqa: E501 - """Creates a new CSRF token. Previous CSRF tokens are invalidated by this call. # noqa: E501 - - Response -> CSRF token to use in POST requests # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True - >>> thread = api.csrf_token_with_http_info(async=True) - >>> result = thread.get() - - :param async bool - :return: InlineResponse200 - If the method is called asynchronously, - returns the request thread. - """ - - all_params = [] # noqa: E501 - all_params.append('async') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in six.iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method csrf_token" % 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']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 - - # Authentication setting - auth_settings = ['csrfAuth'] # noqa: E501 - - return self.api_client.call_api( - '/api/v1/csrf', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='InlineResponse200', # noqa: E501 - auth_settings=auth_settings, - async=params.get('async'), - _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 resend_unconfirmed_txns(self, **kwargs): # noqa: E501 - """resend_unconfirmed_txns # noqa: E501 - - Broadcasts all unconfirmed transactions from the unconfirmed transaction pool # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True - >>> thread = api.resend_unconfirmed_txns(async=True) - >>> result = thread.get() - - :param async bool - :return: None - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async'): - return self.resend_unconfirmed_txns_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.resend_unconfirmed_txns_with_http_info(**kwargs) # noqa: E501 - return data - - def resend_unconfirmed_txns_with_http_info(self, **kwargs): # noqa: E501 - """resend_unconfirmed_txns # noqa: E501 - - Broadcasts all unconfirmed transactions from the unconfirmed transaction pool # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True - >>> thread = api.resend_unconfirmed_txns_with_http_info(async=True) - >>> result = thread.get() - - :param async bool - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = [] # noqa: E501 - all_params.append('async') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in six.iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method resend_unconfirmed_txns" % 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']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 - - # Authentication setting - auth_settings = ['csrfAuth'] # noqa: E501 - - return self.api_client.call_api( - '/api/v1/resendUnconfirmedTxns', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async=params.get('async'), - _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 version(self, **kwargs): # noqa: E501 - """version # noqa: E501 - - versionHandler returns the application version info # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True - >>> thread = api.version(async=True) - >>> result = thread.get() - - :param async bool - :return: BuildInfo - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async'): - return self.version_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.version_with_http_info(**kwargs) # noqa: E501 - return data - - def version_with_http_info(self, **kwargs): # noqa: E501 - """version # noqa: E501 - - versionHandler returns the application version info # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True - >>> thread = api.version_with_http_info(async=True) - >>> result = thread.get() - - :param async bool - :return: BuildInfo - If the method is called asynchronously, - returns the request thread. - """ - - all_params = [] # noqa: E501 - all_params.append('async') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in six.iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method version" % 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']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 - - # Authentication setting - auth_settings = ['csrfAuth'] # noqa: E501 - - return self.api_client.call_api( - '/api/v1/version', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='BuildInfo', # noqa: E501 - auth_settings=auth_settings, - async=params.get('async'), - _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 wallet_folder(self, **kwargs): # noqa: E501 - """wallet_folder # noqa: E501 - - Returns the wallet directory path # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True - >>> thread = api.wallet_folder(async=True) - >>> result = thread.get() - - :param async bool - :return: None - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async'): - return self.wallet_folder_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.wallet_folder_with_http_info(**kwargs) # noqa: E501 - return data - - def wallet_folder_with_http_info(self, **kwargs): # noqa: E501 - """wallet_folder # noqa: E501 - - Returns the wallet directory path # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async=True - >>> thread = api.wallet_folder_with_http_info(async=True) - >>> result = thread.get() - - :param async bool - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = [] # noqa: E501 - all_params.append('async') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in six.iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method wallet_folder" % 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']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 - - # Authentication setting - auth_settings = ['csrfAuth'] # noqa: E501 - - return self.api_client.call_api( - '/api/v1/wallets/folderName', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async=params.get('async'), - _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/skycoin/restapi/api_client.py b/skycoin/restapi/api_client.py deleted file mode 100644 index fcaec015..00000000 --- a/skycoin/restapi/api_client.py +++ /dev/null @@ -1,620 +0,0 @@ -# coding: utf-8 -""" - - No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: contact@skycoin.net - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - -from __future__ import absolute_import - -import datetime -import json -import mimetypes -from multiprocessing.pool import ThreadPool -import os -import re -import tempfile - -# python 2 and python 3 compatibility library -import six -from six.moves.urllib.parse import quote - -from swagger_client.configuration import Configuration -import swagger_client.models -from swagger_client import rest - - -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 configuration: .Configuration object for this client - :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. - :param cookie: a cookie to include in the header when making calls - to the API - """ - - PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types - NATIVE_TYPES_MAPPING = { - 'int': int, - 'long': int if six.PY3 else long, # noqa: F821 - 'float': float, - 'str': str, - 'bool': bool, - 'date': datetime.date, - 'datetime': datetime.datetime, - 'object': object, - } - - def __init__(self, configuration=None, header_name=None, header_value=None, - cookie=None): - if configuration is None: - configuration = Configuration() - self.configuration = configuration - - self.pool = ThreadPool() - self.rest_client = rest.RESTClientObject(configuration) - self.default_headers = {} - if header_name is not None: - self.default_headers[header_name] = header_value - self.cookie = cookie - # Set default User-Agent. - self.user_agent = 'Swagger-Codegen/1.0.0/python' - - def __del__(self): - self.pool.close() - self.pool.join() - - @property - def user_agent(self): - """User agent for this API client""" - return self.default_headers['User-Agent'] - - @user_agent.setter - def user_agent(self, value): - 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, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None): - - config = self.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.configuration.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 _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.datetime, 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 six.iteritems(obj.swagger_types) - if getattr(obj, attr) is not None} - - return {key: self.sanitize_for_serialization(val) - for key, val in six.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 six.iteritems(data)} - - # convert str to class - if klass in self.NATIVE_TYPES_MAPPING: - klass = self.NATIVE_TYPES_MAPPING[klass] - else: - klass = getattr(swagger_client.models, klass) - - if klass in self.PRIMITIVE_TYPES: - return self.__deserialize_primitive(data, klass) - elif klass == object: - return self.__deserialize_object(data) - elif klass == datetime.date: - return self.__deserialize_date(data) - elif klass == datetime.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, async=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None): - """Makes the HTTP request (synchronous) and returns deserialized data. - - To make an async request, set the async parameter. - - :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 async bool: execute request 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 async parameter is True, - the request will be called asynchronously. - The method will return the request thread. - If parameter async is False or missing, - then the method will return the response directly. - """ - if not async: - return self.__call_api(resource_path, method, - path_params, query_params, header_params, - body, post_params, files, - response_type, auth_settings, - _return_http_data_only, collection_formats, - _preload_content, _request_timeout) - else: - thread = self.pool.apply_async(self.__call_api, (resource_path, - method, path_params, query_params, - header_params, body, - post_params, files, - response_type, auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, _request_timeout)) - 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 six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 - 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 six.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. - """ - if not auth_settings: - return - - for auth in auth_settings: - auth_setting = self.configuration.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): - """Deserializes body to file - - 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. - """ - fd, path = tempfile.mkstemp(dir=self.configuration.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, "wb") 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 six.u(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 rest.ApiException( - status=0, - reason="Failed to parse `{0}` as 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 rest.ApiException( - status=0, - reason=( - "Failed to parse `{0}` as 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 and not hasattr(klass, - 'get_real_child_model'): - return data - - kwargs = {} - if klass.swagger_types is not None: - for attr, attr_type in six.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) - - if hasattr(instance, 'get_real_child_model'): - klass_name = instance.get_real_child_model(data) - if klass_name: - instance = self.__deserialize(data, klass_name) - return instance diff --git a/skycoin/restapi/configuration.py b/skycoin/restapi/configuration.py deleted file mode 100644 index 4597667f..00000000 --- a/skycoin/restapi/configuration.py +++ /dev/null @@ -1,246 +0,0 @@ -# coding: utf-8 - -""" - - No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: contact@skycoin.net - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import copy -import logging -import multiprocessing -import sys -import urllib3 - -import six -from six.moves import http_client as httplib - - -class TypeWithDefault(type): - def __init__(cls, name, bases, dct): - super(TypeWithDefault, cls).__init__(name, bases, dct) - cls._default = None - - def __call__(cls): - if cls._default is None: - cls._default = type.__call__(cls) - return copy.copy(cls._default) - - def set_default(cls, default): - cls._default = copy.copy(default) - - -class Configuration(six.with_metaclass(TypeWithDefault, 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 = "http://staging.node.skycoin.net" - # 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_client") - 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 - # Set this to True/False to enable/disable SSL hostname verification. - self.assert_hostname = None - - # urllib3 connection pool's maximum number of connections saved - # per pool. urllib3 uses 1 connection as default value, but this is - # not the best value when you are making a lot of possibly parallel - # requests to the same host, which is often the case here. - # cpu_count * 5 is used as default value to increase performance. - self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 - - # Proxy URL - self.proxy = None - # Safe chars for path_param - self.safe_chars_for_path_param = '' - - @property - def logger_file(self): - """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 - """ - return self.__logger_file - - @logger_file.setter - def logger_file(self, value): - """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 six.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 six.iteritems(self.logger): - logger.addHandler(self.logger_stream_handler) - if self.logger_file_handler: - logger.removeHandler(self.logger_file_handler) - - @property - def debug(self): - """Debug status - - :param value: The debug status, True or False. - :type: bool - """ - return self.__debug - - @debug.setter - def debug(self, value): - """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 six.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 six.iteritems(self.logger): - logger.setLevel(logging.WARNING) - # turn off httplib debug - httplib.HTTPConnection.debuglevel = 0 - - @property - def logger_format(self): - """The logger format. - - The logger_formatter will be updated when sets logger_format. - - :param value: The format string. - :type: str - """ - return self.__logger_format - - @logger_format.setter - def logger_format(self, value): - """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] # noqa: E501 - 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 { - 'csrfAuth': - { - 'type': 'api_key', - 'in': 'header', - 'key': 'csrf_Token', - 'value': self.get_api_key_with_prefix('csrf_Token') - }, - - } - - 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: 1.0.0\n"\ - "SDK Package Version: 1.0.0".\ - format(env=sys.platform, pyversion=sys.version) diff --git a/skycoin/restapi/models/__init__.py b/skycoin/restapi/models/__init__.py deleted file mode 100644 index 46ba4cd9..00000000 --- a/skycoin/restapi/models/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# coding: utf-8 - -# flake8: noqa -""" - - No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: contact@skycoin.net - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -# import models into model package -from swagger_client.models.build_info import BuildInfo -from swagger_client.models.inline_response_200 import InlineResponse200 -from swagger_client.models.inline_response_422 import InlineResponse422 -from swagger_client.models.inline_response_default import InlineResponseDefault diff --git a/skycoin/restapi/models/build_info.py b/skycoin/restapi/models/build_info.py deleted file mode 100644 index 1bbbbf2f..00000000 --- a/skycoin/restapi/models/build_info.py +++ /dev/null @@ -1,169 +0,0 @@ -# coding: utf-8 - -""" - - No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: contact@skycoin.net - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -import pprint -import re # noqa: F401 - -import six - - -class BuildInfo(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 = { - 'branch': 'str', - 'commit': 'str', - 'version': 'str' - } - - attribute_map = { - 'branch': 'branch', - 'commit': 'commit', - 'version': 'version' - } - - def __init__(self, branch=None, commit=None, version=None): # noqa: E501 - """BuildInfo - a model defined in Swagger""" # noqa: E501 - - self._branch = None - self._commit = None - self._version = None - self.discriminator = None - - if branch is not None: - self.branch = branch - if commit is not None: - self.commit = commit - if version is not None: - self.version = version - - @property - def branch(self): - """Gets the branch of this BuildInfo. # noqa: E501 - - git branch name # noqa: E501 - - :return: The branch of this BuildInfo. # noqa: E501 - :rtype: str - """ - return self._branch - - @branch.setter - def branch(self, branch): - """Sets the branch of this BuildInfo. - - git branch name # noqa: E501 - - :param branch: The branch of this BuildInfo. # noqa: E501 - :type: str - """ - - self._branch = branch - - @property - def commit(self): - """Gets the commit of this BuildInfo. # noqa: E501 - - git commit id # noqa: E501 - - :return: The commit of this BuildInfo. # noqa: E501 - :rtype: str - """ - return self._commit - - @commit.setter - def commit(self, commit): - """Sets the commit of this BuildInfo. - - git commit id # noqa: E501 - - :param commit: The commit of this BuildInfo. # noqa: E501 - :type: str - """ - - self._commit = commit - - @property - def version(self): - """Gets the version of this BuildInfo. # noqa: E501 - - version number # noqa: E501 - - :return: The version of this BuildInfo. # noqa: E501 - :rtype: str - """ - return self._version - - @version.setter - def version(self, version): - """Sets the version of this BuildInfo. - - version number # noqa: E501 - - :param version: The version of this BuildInfo. # noqa: E501 - :type: str - """ - - self._version = version - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.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 pprint.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, BuildInfo): - 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/skycoin/restapi/models/inline_response_200.py b/skycoin/restapi/models/inline_response_200.py deleted file mode 100644 index 8c240a5a..00000000 --- a/skycoin/restapi/models/inline_response_200.py +++ /dev/null @@ -1,113 +0,0 @@ -# coding: utf-8 - -""" - - No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: contact@skycoin.net - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -import pprint -import re # noqa: F401 - -import six - - -class InlineResponse200(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 = { - 'csrf_token': 'str' - } - - attribute_map = { - 'csrf_token': 'csrf_token' - } - - def __init__(self, csrf_token=None): # noqa: E501 - """InlineResponse200 - a model defined in Swagger""" # noqa: E501 - - self._csrf_token = None - self.discriminator = None - - if csrf_token is not None: - self.csrf_token = csrf_token - - @property - def csrf_token(self): - """Gets the csrf_token of this InlineResponse200. # noqa: E501 - - Csrf Token is here # noqa: E501 - - :return: The csrf_token of this InlineResponse200. # noqa: E501 - :rtype: str - """ - return self._csrf_token - - @csrf_token.setter - def csrf_token(self, csrf_token): - """Sets the csrf_token of this InlineResponse200. - - Csrf Token is here # noqa: E501 - - :param csrf_token: The csrf_token of this InlineResponse200. # noqa: E501 - :type: str - """ - - self._csrf_token = csrf_token - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.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 pprint.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, InlineResponse200): - 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/skycoin/restapi/models/inline_response_422.py b/skycoin/restapi/models/inline_response_422.py deleted file mode 100644 index 9c1637ef..00000000 --- a/skycoin/restapi/models/inline_response_422.py +++ /dev/null @@ -1,163 +0,0 @@ -# coding: utf-8 - -""" - - No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: contact@skycoin.net - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -import pprint -import re # noqa: F401 - -import six - - -class InlineResponse422(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', - 'field': 'str', - 'message': 'str' - } - - attribute_map = { - 'code': 'code', - 'field': 'field', - 'message': 'message' - } - - def __init__(self, code=None, field=None, message=None): # noqa: E501 - """InlineResponse422 - a model defined in Swagger""" # noqa: E501 - - self._code = None - self._field = None - self._message = None - self.discriminator = None - - if code is not None: - self.code = code - if field is not None: - self.field = field - if message is not None: - self.message = message - - @property - def code(self): - """Gets the code of this InlineResponse422. # noqa: E501 - - - :return: The code of this InlineResponse422. # noqa: E501 - :rtype: int - """ - return self._code - - @code.setter - def code(self, code): - """Sets the code of this InlineResponse422. - - - :param code: The code of this InlineResponse422. # noqa: E501 - :type: int - """ - - self._code = code - - @property - def field(self): - """Gets the field of this InlineResponse422. # noqa: E501 - - - :return: The field of this InlineResponse422. # noqa: E501 - :rtype: str - """ - return self._field - - @field.setter - def field(self, field): - """Sets the field of this InlineResponse422. - - - :param field: The field of this InlineResponse422. # noqa: E501 - :type: str - """ - - self._field = field - - @property - def message(self): - """Gets the message of this InlineResponse422. # noqa: E501 - - - :return: The message of this InlineResponse422. # noqa: E501 - :rtype: str - """ - return self._message - - @message.setter - def message(self, message): - """Sets the message of this InlineResponse422. - - - :param message: The message of this InlineResponse422. # noqa: E501 - :type: str - """ - - self._message = message - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.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 pprint.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, InlineResponse422): - 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/skycoin/restapi/models/inline_response_default.py b/skycoin/restapi/models/inline_response_default.py deleted file mode 100644 index 10e94157..00000000 --- a/skycoin/restapi/models/inline_response_default.py +++ /dev/null @@ -1,137 +0,0 @@ -# coding: utf-8 - -""" - - No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: contact@skycoin.net - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -import pprint -import re # noqa: F401 - -import six - - -class InlineResponseDefault(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' - } - - attribute_map = { - 'code': 'code', - 'message': 'message' - } - - def __init__(self, code=None, message=None): # noqa: E501 - """InlineResponseDefault - a model defined in Swagger""" # noqa: E501 - - self._code = None - self._message = None - self.discriminator = None - - if code is not None: - self.code = code - if message is not None: - self.message = message - - @property - def code(self): - """Gets the code of this InlineResponseDefault. # noqa: E501 - - - :return: The code of this InlineResponseDefault. # noqa: E501 - :rtype: int - """ - return self._code - - @code.setter - def code(self, code): - """Sets the code of this InlineResponseDefault. - - - :param code: The code of this InlineResponseDefault. # noqa: E501 - :type: int - """ - - self._code = code - - @property - def message(self): - """Gets the message of this InlineResponseDefault. # noqa: E501 - - - :return: The message of this InlineResponseDefault. # noqa: E501 - :rtype: str - """ - return self._message - - @message.setter - def message(self, message): - """Sets the message of this InlineResponseDefault. - - - :param message: The message of this InlineResponseDefault. # noqa: E501 - :type: str - """ - - self._message = message - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.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 pprint.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, InlineResponseDefault): - 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/skycoin/restapi/rest.py b/skycoin/restapi/rest.py deleted file mode 100644 index ed2892c0..00000000 --- a/skycoin/restapi/rest.py +++ /dev/null @@ -1,322 +0,0 @@ -# coding: utf-8 - -""" - - No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: contact@skycoin.net - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - - -from __future__ import absolute_import - -import io -import json -import logging -import re -import ssl - -import certifi -# python 2 and python 3 compatibility library -import six -from six.moves.urllib.parse import urlencode - -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, configuration, pools_size=4, maxsize=None): - # urllib3.PoolManager will pass all kw parameters to connectionpool - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 - # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 - # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 - - # 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() - - addition_pool_args = {} - if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 - - if maxsize is None: - if configuration.connection_pool_maxsize is not None: - maxsize = configuration.connection_pool_maxsize - else: - maxsize = 4 - - # https pool manager - if configuration.proxy: - self.pool_manager = urllib3.ProxyManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=ca_certs, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - **addition_pool_args - ) - else: - self.pool_manager = urllib3.PoolManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=ca_certs, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - **addition_pool_args - ) - - def request(self, method, url, query_params=None, headers=None, - body=None, post_params=None, _preload_content=True, - _request_timeout=None): - """Perform requests. - - :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 six.PY3 else (int, long)): # noqa: E501,F821 - 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 is not None: - 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': # noqa: E501 - 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 six.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