Skip to content

Commit

Permalink
Merge pull request #1 from liblaber/v1.0.0-1711577931303
Browse files Browse the repository at this point in the history
liblab SDK update v1.0.0
  • Loading branch information
david-liblab authored Mar 27, 2024
2 parents d60f3c6 + cb34f06 commit 90215cd
Show file tree
Hide file tree
Showing 45 changed files with 2,044 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
123 changes: 123 additions & 0 deletions .manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"liblabVersion": "2.0.22",
"date": "2024-03-27T22:18:46.352Z",
"config": {
"usesFormData": false,
"authentication": {
"access": {
"prefix": "Bearer"
}
},
"environmentVariables": [],
"fileOutput": "/tmp",
"inferServiceNames": false,
"httpLibrary": {
"name": "axios",
"packages": {
"axios": "^1.6.8"
},
"languages": ["typescript"]
},
"auth": ["bearer"],
"sdkName": "petstore-sdk",
"sdkVersion": "1.0.0",
"retry": {
"enabled": true,
"maxAttempts": 3,
"retryDelay": 150
},
"multiTenant": true,
"customQueries": {
"paths": [],
"rawQueries": [],
"queriesData": []
},
"generateEnv": true,
"injectedModels": [],
"includeWatermark": false,
"license": {
"type": "MIT"
},
"ignoreFiles": [],
"deliveryMethod": "zip",
"apiId": 604,
"liblabVersion": "2",
"deliveryMethods": ["zip"],
"languages": ["python"],
"apiVersion": "1.0.0",
"apiName": "petstore-api",
"specFilePath": "petstore.json",
"createDocs": false,
"languageOptions": {
"python": {
"alwaysInitializeOptionals": false,
"pypiPackageName": "petstore-pypi",
"githubRepoName": "python-sdk-template",
"ignoreFiles": [],
"liblabVersion": "2",
"sdkVersion": "1.0.0"
}
},
"publishing": {
"githubOrg": "liblaber"
},
"includeOptionalSnippetParameters": true,
"devContainer": false,
"responseHeaders": false,
"specUrl": "https://prod-liblab-api-stack-specs.s3.us-east-1.amazonaws.com/604/open-api-spec.json?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA5P3QKKDKGVNIJ2H7%2F20240327%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240327T221846Z&X-Amz-Expires=43200&X-Amz-Signature=bcee3e3cf0bededd83955ab03eac53b19913ffeed978b8da8cadb6ab721e5cb7&X-Amz-SignedHeaders=host&x-id=GetObject",
"alwaysInitializeOptionals": false,
"pypiPackageName": "petstore-pypi",
"githubRepoName": "python-sdk-template",
"language": "python",
"hooks": {
"enabled": false,
"sourceDir": ""
}
},
"files": [
"src/petstore_sdk/models/base.py",
"src/petstore_sdk/models/utils/json_map.py",
"src/petstore_sdk/models/__init__.py",
"src/petstore_sdk/services/__init__.py",
"src/petstore_sdk/__init__.py",
"src/petstore_sdk/net/__init__.py",
"src/petstore_sdk/net/headers/__init__.py",
"src/petstore_sdk/net/transport/__init__.py",
"src/petstore_sdk/hooks/__init__.py",
"src/petstore_sdk/net/environment/__init__.py",
"src/petstore_sdk/net/request_chain/__init__.py",
"src/petstore_sdk/net/request_chain/handlers/__init__.py",
"src/petstore_sdk/net/transport/request.py",
"src/petstore_sdk/net/transport/response.py",
"src/petstore_sdk/net/transport/request_error.py",
"src/petstore_sdk/sdk.py",
"src/petstore_sdk/net/transport/serializer.py",
"src/petstore_sdk/services/utils/validator.py",
"src/petstore_sdk/services/utils/base_service.py",
"pyproject.toml",
".gitignore",
"src/petstore_sdk/models/utils/cast_models.py",
"src/petstore_sdk/net/transport/utils.py",
"src/petstore_sdk/hooks/hook.py",
"install.sh",
"install.cmd",
"examples/install.sh",
"examples/install.cmd",
"src/petstore_sdk/net/headers/base_header.py",
"src/petstore_sdk/net/headers/access_token_auth.py",
"src/petstore_sdk/net/environment/environment.py",
"src/petstore_sdk/net/request_chain/request_chain.py",
"src/petstore_sdk/net/request_chain/handlers/base_handler.py",
"src/petstore_sdk/net/request_chain/handlers/http_handler.py",
"src/petstore_sdk/net/request_chain/handlers/hook_handler.py",
"src/petstore_sdk/net/request_chain/handlers/retry_handler.py",
"examples/sample.py",
".env.example",
"/examples/.env.example",
"src/petstore_sdk/services/utils/default_headers.py",
"./LICENSE",
"src/petstore_sdk/models/pet.py",
"src/petstore_sdk/services/pets.py",
"README.md"
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
95 changes: 94 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,94 @@
# python-sdk-template
# PetstoreSdk Python SDK 1.0.0

A Python SDK for PetstoreSdk.

- API version: 1.0.0
- SDK version: 1.0.0

## Table of Contents

- [Installation](#installation)
- [Authentication](#authentication)
- [Services](#services)

## Installation

```bash
pip install petstore-pypi
```

## Authentication

### Access Token

The PetstoreSdk API uses a access token as a form of authentication.

The access token can be set when initializing the SDK like this:

```py
PetstoreSdk(
access_token="YOUR_ACCESS_TOKEN"
)
```

Or at a later stage:

```py
sdk.set_access_token("YOUR_ACCESS_TOKEN")
```

## Services

### PetsService

#### **list_pets**

```py
from petstore_sdk import PetstoreSdk, Environment

sdk = PetstoreSdk(
access_token="YOUR_ACCESS_TOKEN",
base_url=Environment.DEFAULT.value
)

result = sdk.pets.list_pets(limit=24)

print(result)
```

#### **create_pets**

```py
from petstore_sdk import PetstoreSdk, Environment
from petstore_sdk.models import Pet

sdk = PetstoreSdk(
access_token="YOUR_ACCESS_TOKEN",
base_url=Environment.DEFAULT.value
)

request_body = Pet(**{
"id_": 3,
"name": "name",
"tag": "tag"
})

result = sdk.pets.create_pets(request_body=request_body)

print(result)
```

#### **show_pet_by_id**

```py
from petstore_sdk import PetstoreSdk, Environment

sdk = PetstoreSdk(
access_token="YOUR_ACCESS_TOKEN",
base_url=Environment.DEFAULT.value
)

result = sdk.pets.show_pet_by_id(pet_id="petId")

print(result)
```
1 change: 1 addition & 0 deletions examples/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

6 changes: 6 additions & 0 deletions examples/install.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
python -m venv .venv
call .venv\Scripts\activate
pip install build
python -m build --outdir dist ..\
pip install dist\petstore_pypi-1.0.0-py3-none-any.whl --force-reinstall
deactivate
6 changes: 6 additions & 0 deletions examples/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
python -m venv .venv
. .venv/bin/activate
pip install build
python -m build --outdir dist ../
pip install dist/petstore_pypi-1.0.0-py3-none-any.whl --force-reinstall
deactivate
7 changes: 7 additions & 0 deletions examples/sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from petstore_sdk import PetstoreSdk, Environment

sdk = PetstoreSdk(access_token="YOUR_ACCESS_TOKEN", base_url=Environment.DEFAULT.value)

result = sdk.pets.list_pets(limit=24)

print(result)
22 changes: 22 additions & 0 deletions install.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@echo off
set USE_VENV=0

:loop
if "%~1"=="" goto afterloop
if "%~1"=="--use-venv" set USE_VENV=1
shift
goto loop
:afterloop

if "%USE_VENV%"=="1" (
python -m venv .venv
call .venv\Scripts\activate
)

pip install build
python -m build --outdir dist .
pip install dist\petstore_pypi-1.0.0-py3-none-any.whl --force-reinstall

if "%USE_VENV%"=="1" (
deactivate
)
26 changes: 26 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

USE_VENV=0

for arg in "$@"
do
case $arg in
--use-venv)
USE_VENV=1
shift
;;
esac
done

if [ "$USE_VENV" -eq 1 ]; then
python -m venv .venv
. .venv/bin/activate
fi

pip install build
python -m build --outdir dist .
pip install dist/petstore_pypi-1.0.0-py3-none-any.whl --force-reinstall

if [ "$USE_VENV" -eq 1 ]; then
deactivate
fi
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "petstore-pypi"
version = "1.0.0"
license = { text = "MIT" }
description = """"""
readme = "README.md"
requires-python = ">=3.7"
dependencies = [
"requests>=2.31.0"
]
2 changes: 2 additions & 0 deletions src/petstore_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .sdk import PetstoreSdk
from .net.environment import Environment
Empty file.
33 changes: 33 additions & 0 deletions src/petstore_sdk/hooks/hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class Request:
def __init__(self, method, url, headers, body=""):
self.method = method
self.url = url
self.headers = headers
self.body = body

def __str__(self):
return f"method={self.method}, url={self.url}, headers={self.headers}, body={self.body})"


class Response:
def __init__(self, status, headers, body):
self.status = status
self.headers = headers
self.body = body

def __str__(self):
return "Response(status={}, headers={}, body={})".format(
self.status, self.headers, self.body
)


class DefaultHook:

def before_request(self, request: Request):
pass

def after_response(self, request: Request, response: Response):
pass

def on_error(self, error: Exception, request: Request, response: Response):
pass
1 change: 1 addition & 0 deletions src/petstore_sdk/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .pet import Pet
Loading

0 comments on commit 90215cd

Please sign in to comment.