8000 Generated the first version of the python cli via swagger · fspv/python-leetcode@44906a3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 44906a3

Browse files
committed
Generated the first version of the python cli via swagger
0 parents  commit 44906a3

33 files changed

+3262
-0
lines changed

.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
venv/
48+
.python-version
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
57+
# Sphinx documentation
58+
docs/_build/
59+
60+
# PyBuilder
61+
target/
62+
63+
#Ipython Notebook
64+
.ipynb_checkpoints

.swagger-codegen-ignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Swagger Codegen Ignore
2+
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

.swagger-codegen/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0.27

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ref: https://docs.travis-ci.com/user/languages/python
2+
language: python
3+
python:
4+
- "3.2"
5+
- "3.3"
6+
- "3.4"
7+
- "3.5"
8+
#- "3.5-dev" # 3.5 development branch
9+
#- "nightly" # points to the latest development branch e.g. 3.6-dev
10+
# command to install dependencies
11+
install: "pip install -r requirements.txt"
12+
# command to run tests
13+
script: nosetests

README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# swagger-client
2+
This is a simple API
3+
4+
This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
5+
6+
- API version: 1.0.0-oas3
7+
- Package version: 1.0.0
8+
- Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen
9+
10+
## Requirements.
11+
12+
Python 2.7 and 3.4+
13+
14+
## Installation & Usage
15+
### pip install
16+
17+
If the python package is hosted on Github, you can install directly from Github
18+
19+
```sh
20+
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
21+
```
22+
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)
23+
24+
Then import the package:
25+
```python
26+
import swagger_client
27+
```
28+
29+
### Setuptools
30+
31+
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
32+
33+
```sh
34+
python setup.py install --user
35+
```
36+
(or `sudo python setup.py install` to install the package for all users)
37+
38+
Then import the package:
39+
```python
40+
import swagger_client
41+
```
42+
43+
## Getting Started
44+
45+
Please follow the [installation procedure](#installation--usage) and then run the following:
46+
47+
```python
48+
from __future__ import print_function
49+
import time
50+
import swagger_client
51+
from swagger_client.rest import ApiException
52+
from pprint import pprint
53+
54+
# Configure API key authorization: cookieCSRF
55+
configuration = swagger_client.Configuration()
56+
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
57+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
58+
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
59+
# Configure API key authorization: cookieSession
60+
configuration = swagger_client.Configuration()
61+
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
62+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
63+
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
64+
65+
# create an instance of the API class
66+
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
67+
68+
try:
69+
api_response = api_instance.problems_algorithms_get()
70+
pprint(api_response)
71+
except ApiException as e:
72+
print("Exception when calling DefaultApi->problems_algorithms_get: %s\n" % e)
73+
```
74+
75+
## Documentation for API Endpoints
76+
77+
All URIs are relative to *https://leetcode.com/api*
78+
79+
Class | Method | HTTP request | Description
80+
------------ | ------------- | ------------- | -------------
81+
*DefaultApi* | [**problems_algorithms_get**](docs/DefaultApi.md#problems_algorithms_get) | **GET** /problems/algorithms/ |
82+
83+
## Documentation For Models
84+
85+
- [Difficulty](docs/Difficulty.md)
86+
- [Problems](docs/Problems.md)
87+
- [Stat](docs/Stat.md)
88+
- [StatStatusPair](docs/StatStatusPair.md)
89+
90+
## Documentation For Authorization
91+
92+
93+
## cookieCSRF
94+
95+
- **Type**: API key
96+
- **API key parameter name**: csrftoken
97+
- **Location**: URL query string
98+
99+
## cookieSession
100+
101+
- **Type**: API key
102+
- **API key parameter name**: LEETCODE_SESSION
103+
- **Location**: URL query string
104+
105+
106+
## Author
107+
108+
pv.safronov@gmail.com

docs/DefaultApi.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# swagger_client.DefaultApi
2+
3+
All URIs are relative to *https://leetcode.com/api*
4+
5+
Method | HTTP request | Description
6+
------------- | ------------- | -------------
7+
[**problems_algorithms_get**](DefaultApi.md#problems_algorithms_get) | **GET** /problems/algorithms/ |
8+
9+
# **problems_algorithms_get**
10+
> Problems problems_algorithms_get()
11+
12+
13+
14+
### Example
15+
```python
16+
from __future__ import print_function
17+
import time
18+
import swagger_client
19+
from swagger_client.rest import ApiException
20+
from pprint import pprint
21+
22+
# Configure API key authorization: cookieCSRF
23+
configuration = swagger_client.Configuration()
24+
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
25+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
26+
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
27+
# Configure API key authorization: cookieSession
28+
configuration = swagger_client.Configuration()
29+
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
30+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
31+
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
32+
33+
# create an instance of the API class
34+
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
35+
36+
try:
37+
api_response = api_instance.problems_algorithms_get()
38+
pprint(api_response)
39+
except ApiException as e:
40+
print("Exception when calling DefaultApi->problems_algorithms_get: %s\n" % e)
41+
```
42+
43+
### Parameters
44+
This endpoint does not need any parameter.
45+
46+
### Return type
47+
48+
[**Problems**](Problems.md)
49+
50+
### Authorization
51+
52+
[cookieCSRF](../README.md#cookieCSRF), [cookieSession](../README.md#cookieSession)
53+
54+
### HTTP request headers
55+
56+
- **Content-Type**: Not defined
57+
- **Accept**: application/json
58+
59+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
60+

docs/Difficulty.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 10000 Difficulty
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**level** | **int** | |
7+
8+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
9+

docs/Problems.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Problems
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**user_name** | **str** | |
7+
**num_solved** | **int** | |
8+
**num_total** | **int** | |
9+
**ac_easy** | **int** | |
10+
**ac_medium** | **int** | |
11+
**ac_hard** | **int** | |
12+
**stat_status_pairs** | [**list[StatStatusPair]**](StatStatusPair.md) | |
13+
**frequency_high** | **int** | |
14+
**frequency_mid** | **int** | |
15+
**category_slug** | **str** | |
16+
17+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
18+

docs/Stat.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Stat
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**question_id** | **int** | |
7+
**question__article__live** | **str** | | [optional]
8+
**question__article__slug** | **str** | | [optional]
9+
**question__article__has_video_solution** | **str** | | [optional]
10+
**question__title** | **str** | |
11+
**question__title_slug** | **str** | |
12+
**question__hide** | **bool** | |
13+
**total_acs** | **int** | |
14+
**total_submitted** | **int** | |
15+
**frontend_question_id** | **int** | |
16+
**is_new_question** | **bool** | |
17+
18+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
19+

docs/StatStatusPair.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# StatStatusPair
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**stat** | [**Stat**](Stat.md) | |
7+
**status** | **str** | | [optional]
8+
**difficulty** | [**Difficulty**](Difficulty.md) | |
9+
**paid_only** | **bool** | |
10+
**is_favor** | **bool** | |
11+
**frequency** | **float** | |
12+
**progress** | **float** | |
13+
14+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
15+

git_push.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3+
#
4+
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
5+
6+
git_user_id=$1
7+
git_repo_id=$2
8+
release_n 10000 ote=$3
9+
10+
if [ "$git_user_id" = "" ]; then
11+
git_user_id="GIT_USER_ID"
12+
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
13+
fi
14+
15+
if [ "$git_repo_id" = "" ]; then
16+
git_repo_id="GIT_REPO_ID"
17+
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
18+
fi
19+
20+
if [ "$release_note" = "" ]; then
21+
release_note="Minor update"
22+
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
23+
fi
24+
25+
# Initialize the local directory as a Git repository
26+
git init
27+
28+
# Adds the files in the local repository and stages them for commit.
29+
git add .
30+
31+
# Commits the tracked changes and prepares them to be pushed to a remote repository.
32+
git commit -m "$release_note"
33+
34+
# Sets the new remote
35+
git_remote=`git remote`
36+
if [ "$git_remote" = "" ]; then # git remote not defined
37+
38+
if [ "$GIT_TOKEN" = "" ]; then
39+
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
40+
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
41+
else
42+
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
43+
fi
44+
45+
fi
46+
47+
git pull origin master
48+
49+
# Pushes (Forces) the changes in the local repository up to the remote repository
50+
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
51+
git push origin master 2>&1 | grep -v 'To https'
52+

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
certifi >= 14.05.14
2+
six >= 1.10
3+
python_dateutil >= 2.5.3
4+
setuptools >= 21.0.0
5+
urllib3 >= 1.15.1

0 commit comments

Comments
 (0)
0