Skip to content

Commit 891d54d

Browse files
committed
Release v0.0.2
1 parent 68fb8a6 commit 891d54d

File tree

8 files changed

+36
-48
lines changed

8 files changed

+36
-48
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ build-spec: ## build the entire localstack api spec (openapi.yaml in the root
1919

2020
clean: ## Clean up the virtual environment
2121
rm -rf $(VENV_DIR)
22+
rm -rf dist/
2223

2324
clean-generated: ## Cleanup generated code
2425
rm -rf packages/localstack-sdk-generated/localstack/

README.md

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,26 @@
11
# LocalStack Python SDK
22

3-
This repository is a PoC for generating a Python SDK for the LocalStack public endpoint.
4-
5-
### Generate the spec
6-
7-
The first step is to generate the `openapi.yaml` spec.
8-
We have a script in `scripts/create_spec.py`
9-
- [ ] todo: fix the script; make sure it also fetches ext spec;
10-
`localstack-core` and `localstack-ext` are part of the dev dependencies for this very step.
11-
12-
### Generate the code
13-
We use openapi-generator from `openapitools`.
14-
To run the generation, run `./bin/generate.sh`.
15-
The script uses the docker image of the CLI and use the `openapi.yaml` file as input.
16-
By default, the generator creates a bunch of files, but the most important things are:
17-
- `api` package: with the all APIs categorized by tags;
18-
- `models` package: with the methods derived from the components or the inline specs;
19-
- [ ] the code from the inline components is much uglier, but we can overwrite some naming with come config (or move to components).
20-
21-
The python generator by default creates 3 functions for each path:
22-
- a normal function (the name is taken from the `operationId` in the specs) just with the validated response payload;
23-
- a function suffixed by `without_preloaded_content`: where the JSON responses are not validated;
24-
- a function suffixed by `with_http_info` which also returns the response header and status.
25-
26-
The code in these `api` files (but also in any other generated artifacts), can be modified by providing custom mustache templates.
27-
[These](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/python) are the
28-
default for Python.
29-
Templates are not super immediate, but looking at them and at the generated code you can do it.
30-
For instance, I deleted the `without_preloaded_content` and `with_http_info` generated functions.
31-
32-
### Supporting files
33-
The generated code uses some supporting files, i.e., some utilities that are responsible of making the actual HTTP calls,
34-
validating and parsing the responses.
35-
I just checked in this code and take it as granted, but I am pretty sure we can come up with some simpler code and avoid
36-
to generate this part (would move out from `generated`).
37-
- [ ] see if I can write my own api client and all the necessary supporting code.
38-
39-
### TODO
40-
- [ ] understand if this can be viable at all;
41-
- [ ] devise a way to update the spec automatically and regenerate every time the code in `generated`;
42-
- much more...fill this list up
3+
This is the Python SDK for LocalStack.
4+
LocalStack offers a number of developer endpoints (see [docs](https://docs.localstack.cloud/references/internal-endpoints/)).
5+
This SDK provides a programmatic and easy way to interact with them.
6+
7+
> [!WARNING]
8+
> This project is still in a preview phase, and will be subject to fast and breaking changes.
9+
10+
### Project Structure
11+
12+
This project follows the following structure:
13+
14+
- `packages/localstack-sdk-generated` is a python project generated from the OpenAPI specs with [openapi-generator](https://github.com/OpenAPITools/openapi-generator).
15+
- `localstack-sdk-python` is the main project that has `localstack-sdk-generated` has the main dependency.
16+
17+
Developers are not supposed to modify at all `localstack-sdk-generated`.
18+
The code needs to be every time re-generated from specs using the `generate.sh` script in the `bin` folder.
19+
20+
This project uses [uv](https://github.com/astral-sh/uv) as package/project manager.
21+
22+
### Install & Run
23+
24+
You can simply run `make install-dev` to install the two packages and the needed dependencies.
25+
`make test` runs the test suite.
26+
Note that LocalStack (pro) should be running in the background to execute the test.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.1
1+
0.0.2

packages/localstack-sdk-generated/localstack/sdk/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(
9191
self.default_headers[header_name] = header_value
9292
self.cookie = cookie
9393
# Set default User-Agent.
94-
self.user_agent = 'OpenAPI-Generator/0.0.1/python'
94+
self.user_agent = 'OpenAPI-Generator/0.0.2/python'
9595
self.client_side_validation = configuration.client_side_validation
9696

9797
def __enter__(self):

packages/localstack-sdk-generated/localstack/sdk/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def to_debug_report(self):
385385
"OS: {env}\n"\
386386
"Python Version: {pyversion}\n"\
387387
"Version of the API: 3.8.1.dev4\n"\
388-
"SDK Package Version: 0.0.1".\
388+
"SDK Package Version: 0.0.2".\
389389
format(env=sys.platform, pyversion=sys.version)
390390

391391
def get_host_settings(self):

packages/localstack-sdk-generated/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "localstack-sdk-generated"
3-
version = "0.0.1"
3+
version = "0.0.2"
44
description = "LocalStack REST API - Generated Code"
55
authors = [
66
{ name = "LocalStack Contributors", email = "info@localstack.cloud" }

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "Python SDK for LocalStack"
55
authors = [
66
{ name = "LocalStack Team", email = "info@localstack.cloud"}
77
]
8-
version = "0.0.1"
8+
version = "0.0.2"
99
dependencies = [
1010
"localstack-sdk-generated"
1111
]
@@ -20,6 +20,9 @@ Issues = "https://github.com/localstack/localstack-sdk-python/issues"
2020
requires = ["setuptools>=64"]
2121
build-backend = "setuptools.build_meta"
2222

23+
[tool.setuptools.dynamic]
24+
readme = { file = ["README.md"], content-type = "text/markdown"}
25+
2326
[tool.uv]
2427
dev-dependencies=[
2528
"pytest",
@@ -77,4 +80,4 @@ ignore = [
7780
"T201", # TODO `print` found
7881
"T203", # TODO `pprint` found
7982
]
80-
select = ["B", "C", "E", "F", "I", "W", "T", "B9", "G"]
83+
select = ["B", "C", "E", "F", "I", "W", "T", "B9", "G"]

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)