Skip to content

Commit

Permalink
Merge pull request #8 from waylayio/chore/regenerate
Browse files Browse the repository at this point in the history
Regenerate storage sdk 🔁
  • Loading branch information
plankthom authored Apr 23, 2024
2 parents 15c28ad + 3f37593 commit ee458ca
Show file tree
Hide file tree
Showing 81 changed files with 712 additions and 456 deletions.
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,15 @@ from waylay.sdk.api.api_exceptions import ApiError
waylay_client = WaylayClient.from_profile()

# Note that the typed model classes for responses/parameters/... are only available when `waylay-sdk-storage-types` is installed
from waylay.services.storage.models.tenant_status_report import TenantStatusReport
try:
# Status
# calls `GET /storage/v1/status`
api_response = await waylay_client.storage.about.status(
# query parameters:
query = {
'include_buckets': True
'include_queues': True
'include_disk_usage': False
},
# Version
# calls `GET /storage/v1/`
api_response = await waylay_client.storage.about.version(
)
print("The response of storage.about.status:\n")
print("The response of storage.about.version:\n")
pprint(api_response)
except ApiError as e:
print("Exception when calling storage.about.status: %s\n" % e)
print("Exception when calling storage.about.version: %s\n" % e)
```


Expand All @@ -63,8 +56,8 @@ All URIs are relative to *https://api.waylay.io*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AboutApi* | [**get**](docs/AboutApi.md#get) | **GET** /storage/v1/ | Version
*AboutApi* | [**status**](docs/AboutApi.md#status) | **GET** /storage/v1/status | Status
*AboutApi* | [**version**](docs/AboutApi.md#version) | **GET** /storage/v1/ | Version
*BucketApi* | [**get**](docs/BucketApi.md#get) | **GET** /storage/v1/bucket/{bucket_name} | Get Bucket
*BucketApi* | [**list**](docs/BucketApi.md#list) | **GET** /storage/v1/bucket | List Buckets
*ObjectApi* | [**copy_or_move**](docs/ObjectApi.md#copy_or_move) | **PUT** /storage/v1/bucket/{bucket_name}/{target_path} | Copy Or Move Object
Expand Down
84 changes: 42 additions & 42 deletions docs/AboutApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ All URIs are relative to *https://api.waylay.io*

Method | HTTP request | Description
------------- | ------------- | -------------
[**get**](AboutApi.md#get) | **GET** /storage/v1/ | Version
[**status**](AboutApi.md#status) | **GET** /storage/v1/status | Status
[**version**](AboutApi.md#version) | **GET** /storage/v1/ | Version

# **get**
> get(
# **status**
> status(
> query: StatusQuery,
> headers
> ) -> str
> ) -> TenantStatusReport
Version
Status

Get the application version.
Validate consistency of buckets and notification queues for this tenant.

### Example

Expand All @@ -29,31 +30,44 @@ from waylay.sdk.api.api_exceptions import ApiError
waylay_client = WaylayClient.from_profile()

# Note that the typed model classes for responses/parameters/... are only available when `waylay-sdk-storage-types` is installed
from waylay.services.storage.models.tenant_status_report import TenantStatusReport
try:
# Version
# calls `GET /storage/v1/`
api_response = await waylay_client.storage.about.get(
# Status
# calls `GET /storage/v1/status`
api_response = await waylay_client.storage.about.status(
# query parameters:
query = {
'include_buckets': True
'include_queues': True
'include_disk_usage': False
},
)
print("The response of storage.about.get:\n")
print("The response of storage.about.status:\n")
pprint(api_response)
except ApiError as e:
print("Exception when calling storage.about.get: %s\n" % e)
print("Exception when calling storage.about.status: %s\n" % e)
```

### Endpoint
```
GET /storage/v1/
GET /storage/v1/status
```
### Parameters

This endpoint does not need any parameter.
Name | Type | API binding | Description | Notes
-------- | ----- | ------------- | ------------- | -------------
**query** | [QueryParamTypes](Operation.md#req_arg_query) \| **None** | URL query parameter | |
**query['store']** (dict) <br> **query.store** (Query) | **str** | query parameter `"store"` | | [optional]
**query['include_buckets']** (dict) <br> **query.include_buckets** (Query) | **bool** | query parameter `"include_buckets"` | | [optional] [default True]
**query['include_queues']** (dict) <br> **query.include_queues** (Query) | **bool** | query parameter `"include_queues"` | | [optional] [default True]
**query['include_disk_usage']** (dict) <br> **query.include_disk_usage** (Query) | **bool** | query parameter `"include_disk_usage"` | | [optional] [default False]
**headers** | [HeaderTypes](Operation.md#req_headers) | request headers | |

### Return type

Selected path param | Raw response param | Return Type | Description | Links
------------------- | ------------------ | ------------ | ----------- | -----
Literal[""] _(default)_ | False _(default)_ | **`str`** | |
Literal[""] _(default)_ | False _(default)_ | **`TenantStatusReport`** | | [TenantStatusReport](TenantStatusReport.md)
str | False _(default)_ | **`Any`** | If any other string value for the selected path is provided, the exact type of the response will only be known at runtime. |
/ | True | `Response` | The raw http response object.

Expand All @@ -67,18 +81,18 @@ str | False _(default)_ | **`Any`** | If any other string value for the selected
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Successful Response | - |
**422** | Validation Error | - |

[[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)

# **status**
> status(
> query: StatusQuery,
# **version**
> version(
> headers
> ) -> TenantStatusReport
> ) -> str
Status
Version

Validate consistency of buckets and notification queues for this tenant.
Get the application version.

### Example

Expand All @@ -93,44 +107,31 @@ from waylay.sdk.api.api_exceptions import ApiError
waylay_client = WaylayClient.from_profile()

# Note that the typed model classes for responses/parameters/... are only available when `waylay-sdk-storage-types` is installed
from waylay.services.storage.models.tenant_status_report import TenantStatusReport
try:
# Status
# calls `GET /storage/v1/status`
api_response = await waylay_client.storage.about.status(
# query parameters:
query = {
'include_buckets': True
'include_queues': True
'include_disk_usage': False
},
# Version
# calls `GET /storage/v1/`
api_response = await waylay_client.storage.about.version(
)
print("The response of storage.about.status:\n")
print("The response of storage.about.version:\n")
pprint(api_response)
except ApiError as e:
print("Exception when calling storage.about.status: %s\n" % e)
print("Exception when calling storage.about.version: %s\n" % e)
```

### Endpoint
```
GET /storage/v1/status
GET /storage/v1/
```
### Parameters

Name | Type | API binding | Description | Notes
-------- | ----- | ------------- | ------------- | -------------
**query** | [QueryParamTypes](Operation.md#req_arg_query) \| **None** | URL query parameter | |
**query['store']** (dict) <br> **query.store** (Query) | **str** | query parameter `"store"` | | [optional]
**query['include_buckets']** (dict) <br> **query.include_buckets** (Query) | **bool** | query parameter `"include_buckets"` | | [optional] [default True]
**query['include_queues']** (dict) <br> **query.include_queues** (Query) | **bool** | query parameter `"include_queues"` | | [optional] [default True]
**query['include_disk_usage']** (dict) <br> **query.include_disk_usage** (Query) | **bool** | query parameter `"include_disk_usage"` | | [optional] [default False]
This endpoint does not need any parameter.
**headers** | [HeaderTypes](Operation.md#req_headers) | request headers | |

### Return type

Selected path param | Raw response param | Return Type | Description | Links
------------------- | ------------------ | ------------ | ----------- | -----
Literal[""] _(default)_ | False _(default)_ | **`TenantStatusReport`** | | [TenantStatusReport](TenantStatusReport.md)
Literal[""] _(default)_ | False _(default)_ | **`str`** | |
str | False _(default)_ | **`Any`** | If any other string value for the selected path is provided, the exact type of the response will only be known at runtime. |
/ | True | `Response` | The raw http response object.

Expand All @@ -144,7 +145,6 @@ str | False _(default)_ | **`Any`** | If any other string value for the selected
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Successful Response | - |
**422** | Validation Error | - |

[[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)

2 changes: 2 additions & 0 deletions docs/Operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ response = await waylay_client.demo.gadgets.combatulate_trinket(
raw_response=False,
select_path=None,
response_type=None,
# optional flag to disable the validation of the request arguments when using typed requests
validate_request=True,
# optional named arguments passed to the http client (named)
timeout=10.0,
)
Expand Down
4 changes: 2 additions & 2 deletions openapi/storage.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -764,15 +764,15 @@ paths:
- About
summary: Version
description: Get the application version.
operationId: get_about
operationId: version_about
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: string
title: Response Get
title: Response Version
security: *id001
/storage/v1/status:
get:
Expand Down
6 changes: 3 additions & 3 deletions openapi/storage.transformed.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -920,18 +920,18 @@ paths:
- About
summary: Version
description: Get the application version.
operationId: get_about
operationId: version_about
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: string
title: Response Get
title: Response Version
security:
- waylayApiKeySecret: []
x-py-method: get
x-py-method: version
x-consumes-multipart: false
x-consumes-urlencoded: false
x-consumes-json: false
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pydantic ~= 2.6
typing-extensions ~= 4.9
waylay-sdk-core ~= 0.2.0
waylay-sdk-core ~= 0.2.1
80 changes: 41 additions & 39 deletions test/api/about_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,6 @@ def test_registered(waylay_client: WaylayClient):
assert isinstance(waylay_client.storage.about, AboutApi)


def _get_set_mock_response(httpx_mock: HTTPXMock, gateway_url: str):
mock_response = "''"
httpx_mock_kwargs = {
"method": "GET",
"url": re.compile(f"^{gateway_url}/storage/v1/(\\?.*)?"),
"content": json.dumps(mock_response, default=str),
"status_code": 200,
}
httpx_mock.add_response(**httpx_mock_kwargs)


@pytest.mark.asyncio
@pytest.mark.skipif(not MODELS_AVAILABLE, reason="Types not installed.")
async def test_get(service: StorageService, gateway_url: str, httpx_mock: HTTPXMock):
"""Test case for get
Version
"""
# set path params
kwargs = {}
_get_set_mock_response(httpx_mock, gateway_url)
resp = await service.about.get(**kwargs)
check_type(resp, Union[str,])


@pytest.mark.asyncio
@pytest.mark.skipif(MODELS_AVAILABLE, reason="Types installed.")
async def test_get_without_types(
service: StorageService, gateway_url: str, httpx_mock: HTTPXMock
):
"""Test case for get with models not installed
Version
"""
# set path params
kwargs = {}
_get_set_mock_response(httpx_mock, gateway_url)
resp = await service.about.get(**kwargs)
check_type(resp, Model)


def _status_set_mock_response(httpx_mock: HTTPXMock, gateway_url: str):
mock_response = TenantStatusReportStub.create_json()
httpx_mock_kwargs = {
Expand Down Expand Up @@ -137,3 +98,44 @@ async def test_status_without_types(
_status_set_mock_response(httpx_mock, gateway_url)
resp = await service.about.status(**kwargs)
check_type(resp, Model)


def _version_set_mock_response(httpx_mock: HTTPXMock, gateway_url: str):
mock_response = "''"
httpx_mock_kwargs = {
"method": "GET",
"url": re.compile(f"^{gateway_url}/storage/v1/(\\?.*)?"),
"content": json.dumps(mock_response, default=str),
"status_code": 200,
}
httpx_mock.add_response(**httpx_mock_kwargs)


@pytest.mark.asyncio
@pytest.mark.skipif(not MODELS_AVAILABLE, reason="Types not installed.")
async def test_version(
service: StorageService, gateway_url: str, httpx_mock: HTTPXMock
):
"""Test case for version
Version
"""
# set path params
kwargs = {}
_version_set_mock_response(httpx_mock, gateway_url)
resp = await service.about.version(**kwargs)
check_type(resp, Union[str,])


@pytest.mark.asyncio
@pytest.mark.skipif(MODELS_AVAILABLE, reason="Types installed.")
async def test_version_without_types(
service: StorageService, gateway_url: str, httpx_mock: HTTPXMock
):
"""Test case for version with models not installed
Version
"""
# set path params
kwargs = {}
_version_set_mock_response(httpx_mock, gateway_url)
resp = await service.about.version(**kwargs)
check_type(resp, Model)
3 changes: 3 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Automatic pytest fixtures."""

import random

import httpx
import pytest
import starlette.requests as req
Expand All @@ -8,6 +10,7 @@
from waylay.sdk.auth import NoCredentials
from waylay.services.storage.service import StorageService

random.seed(10)
GATEWAY_URL = "http://example.io"


Expand Down
9 changes: 7 additions & 2 deletions test/types/auth_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ class AUTHStub:
@classmethod
def create_json(cls):
"""Create a dict stub instance."""
return auth_faker.generate()
return auth_faker.generate(use_defaults=True, use_examples=True)

@classmethod
def create_instance(cls) -> "AUTH":
"""Create AUTH stub instance."""
if not MODELS_AVAILABLE:
raise ImportError("Models must be installed to create class stubs")
return AUTHAdapter.validate_python(cls.create_json())
json = cls.create_json()
if not json:
# use backup example based on the pydantic model schema
backup_faker = JSF(AUTHAdapter.json_schema(), allow_none_optionals=1)
json = backup_faker.generate(use_defaults=True, use_examples=True)
return AUTHAdapter.validate_python(json, context={"skip_validation": True})
Loading

0 comments on commit ee458ca

Please sign in to comment.