-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from mobidata-bw/push-feature
push support
- Loading branch information
Showing
42 changed files
with
660 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
### List park api v1 overview data | ||
GET {{api_host}}/api/public/v1/park-api-v1 | ||
GET {{api_host}}/api/public/v1 | ||
|
||
|
||
### List park api v1 detail data | ||
GET {{api_host}}/api/public/v1/park-api-v1/p-r-vrs | ||
GET {{api_host}}/api/public/v1/p-r-vrs | ||
|
||
|
||
### List park api v1 detail data with name filter | ||
GET {{api_host}}/api/public/v1/park-api-v1/example-source?name=Bahnhof | ||
GET {{api_host}}/api/public/v1/example-source?name=Bahnhof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
### List park api v2 detail data | ||
GET {{api_host}}/api/public/v1/park-api-v2/lots/ | ||
GET {{api_host}}/api/public/v2/lots/ | ||
|
||
|
||
### List park api v2 detail data with location filter | ||
GET {{api_host}}/api/public/v1/park-api-v2/lots/?location=12,50&radius=1000 | ||
GET {{api_host}}/api/public/v2/lots/?location=12,50&radius=1000 | ||
|
||
|
||
### List park api v2 detail data with name filter | ||
GET {{api_host}}/api/public/v1/park-api-v2/lots/?name=Bahnhof | ||
GET {{api_host}}/api/public/v2/lots/?name=Bahnhof | ||
|
||
|
||
### List park api v2 pool data | ||
GET {{api_host}}/api/public/v1/park-api-v2/pools/example-source/ | ||
GET {{api_host}}/api/public/v2/pools/example-source/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
### List parking sites | ||
GET {{api_host}}/api/public/v1/parking-sites | ||
GET {{api_host}}/api/public/v3/parking-sites | ||
|
||
|
||
### List parking sites with name filter | ||
GET {{api_host}}/api/public/v1/parking-sites?name=Bahnhof | ||
GET {{api_host}}/api/public/v3/parking-sites?name=Bahnhof | ||
|
||
|
||
### Get single parking site | ||
GET {{api_host}}/api/public/v1/parking-sites/1 | ||
GET {{api_host}}/api/public/v3/parking-sites/1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
""" | ||
Copyright 2023 binary butterfly GmbH | ||
Use of this source code is governed by an MIT-style license that can be found in the LICENSE.txt. | ||
""" | ||
|
||
import argparse | ||
import sys | ||
from getpass import getpass | ||
from pathlib import Path | ||
|
||
import requests | ||
|
||
DATA_TYPES = { | ||
'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', | ||
'csv': 'text/csv', | ||
'xml': 'application/xml', | ||
'json': 'application/json', | ||
} | ||
|
||
PUSH_BASE_URL = 'http://localhost:5000/api/admin/v1/generic-parking-sites' | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
prog='ParkAPI Push Client', | ||
description='This client helps to push static ParkAPI data', | ||
) | ||
parser.add_argument('source_uid') | ||
parser.add_argument('file_path') | ||
args = parser.parse_args() | ||
source_uid: str = args.source_uid | ||
file_path: Path = Path(args.file_path) | ||
|
||
if not file_path.is_file(): | ||
sys.exit('Error: please add a file as second argument.') | ||
|
||
password = getpass(f'Password for source UID {source_uid}: ') | ||
|
||
file_ending = None | ||
for ending in DATA_TYPES: | ||
if file_path.name.endswith(f'.{ending}'): | ||
file_ending = ending | ||
|
||
if file_ending is None: | ||
sys.exit(f'Error: invalid ending. Allowed endings are: {", ".join(DATA_TYPES.keys())}') | ||
|
||
with file_path.open('rb') as file: | ||
file_data = file.read() | ||
|
||
endpoint = f'{PUSH_BASE_URL}/{file_ending}' | ||
requests_response = requests.post( | ||
url=endpoint, | ||
data=file_data, | ||
auth=(source_uid, password), | ||
headers={'Content-Type': DATA_TYPES[file_ending]}, | ||
) | ||
|
||
if requests_response.status_code == 204: | ||
sys.exit('Upload successful.') | ||
|
||
if requests_response.status_code == 401: | ||
sys.exit('Access denied.') | ||
|
||
sys.exit(f'Unknown error with HTTP status code {requests_response.status_code}.') | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
pytest~=7.4.2 | ||
pytest-cov~=4.1.0 | ||
pytest~=7.4.3 | ||
black~=23.10.0 | ||
mypy~=1.6.1 | ||
types-Flask-Migrate~=4.0.0.6 | ||
types-PyYAML~=6.0.12.12 | ||
types-requests~=2.31.0.10 | ||
requests-mock~=1.11.0 | ||
mypy-gitlab-code-quality~=1.0.0 | ||
ruff~=0.1.0 | ||
ruff~=0.1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.