Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into hotfix/bumped-up-vers…
Browse files Browse the repository at this point in the history
…ion-0.0.3
  • Loading branch information
krishnaglodha committed Jun 6, 2024
2 parents 23c9e9e + 8f1f3f5 commit 9538836
Show file tree
Hide file tree
Showing 14 changed files with 894 additions and 730 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pip==23.0
poetry==1.3.2
virtualenv==20.19.0
pip==24.0
poetry==1.8.3
virtualenv==20.26.0
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --upgrade pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
pip install poetry
poetry --version
- name: Check if there is a parent commit
id: check-parent-commit
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install pip
pip --version
- name: Upgrade pip in virtual environments
shell: python
Expand All @@ -45,7 +45,7 @@ jobs:
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
pip install poetry
poetry --version
- name: Install dependencies
run: poetry install
Expand Down
1,479 changes: 825 additions & 654 deletions poetry.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ gsx = "geoserverx.cli.cli:app"

[tool.poetry.dependencies]
python = "^3.9"
httpx = "^0.24.1"
pydantic = "^1.9.1"
typer = "^0.4.1"
rich = "^12.5.1"
mkdocs-material = "^9.0.14"
httpx = "*"
pydantic = "^2.7.2"
typer = "*"
rich = "*"
mkdocs-material = "*"

[tool.poetry.group.dev.dependencies]
pytest = "^7.1.2"
respx = "^0.20.1"
mypy = "^0.960"
black = "^22.3.0"
isort = "^5.10.1"
pytest-asyncio = "^0.21.0"
pytest = "*"
respx = "*"
mypy = "*"
black = "*"
isort = "*"
pytest-asyncio = "*"
anyio = {extras = ["trio"], version = "^3.3.4"}

[build-system]
Expand Down
32 changes: 16 additions & 16 deletions src/geoserverx/_async/gsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ def response_recognise(self, r) -> GSResponse:
resp = GSResponseEnum._200.value
elif r == 409:
resp = GSResponseEnum._409.value
return GSResponse.parse_obj(resp)
return GSResponse.model_validate(resp)

# Get all workspaces
async def get_all_workspaces(self) -> Union[WorkspacesModel, GSResponse]:
Client = self.http_client
responses = await Client.get(f"workspaces")
if responses.status_code == 200:
return WorkspacesModel.parse_obj(responses.json())
return WorkspacesModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -107,7 +107,7 @@ async def get_workspace(self, workspace: str) -> Union[WorkspaceModel, GSRespons
Client = self.http_client
responses = await Client.get(f"workspaces/{workspace}")
if responses.status_code == 200:
return WorkspaceModel.parse_obj(responses.json())
return WorkspaceModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -122,7 +122,7 @@ async def create_workspace(
)
responses = await Client.post(
f"workspaces?default={default}",
data=payload.json(),
data=payload.model_dump_json(),
headers=self.head,
)
results = self.response_recognise(responses.status_code)
Expand All @@ -133,7 +133,7 @@ async def get_vector_stores_in_workspaces(self, workspace: str) -> DataStoresMod
Client = self.http_client
responses = await Client.get(f"workspaces/{workspace}/datastores")
if responses.status_code == 200:
return DataStoresModel.parse_obj(responses.json())
return DataStoresModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -145,7 +145,7 @@ async def get_raster_stores_in_workspaces(
Client = self.http_client
responses = await Client.get(f"workspaces/{workspace}/coveragestores")
if responses.status_code == 200:
return CoveragesStoresModel.parse_obj(responses.json())
return CoveragesStoresModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -156,7 +156,7 @@ async def get_vector_store(self, workspace: str, store: str) -> DataStoreModel:
Client = self.http_client
responses = await Client.get(url)
if responses.status_code == 200:
return DataStoreModel.parse_obj(responses.json())
return DataStoreModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -167,7 +167,7 @@ async def get_raster_store(self, workspace: str, store: str) -> CoveragesStoreMo
Client = self.http_client
responses = await Client.get(url)
if responses.status_code == 200:
return CoveragesStoreModel.parse_obj(responses.json())
return CoveragesStoreModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -177,7 +177,7 @@ async def get_allstyles(self) -> AllStylesModel:
Client = self.http_client
responses = await Client.get(f"styles")
if responses.status_code == 200:
return AllStylesModel.parse_obj(responses.json())
return AllStylesModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -187,7 +187,7 @@ async def get_style(self, style: str) -> StyleModel:
Client = self.http_client
responses = await Client.get(f"styles/{style}.json")
if responses.status_code == 200:
return StyleModel.parse_obj(responses.json())
return StyleModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -213,13 +213,13 @@ async def create_pg_store(
user=username,
passwd=password,
dbtype="postgis",
).dict(exclude_none=True),
).model_dump(exclude_none=True),
)
)
Client = self.http_client
responses = await Client.post(
f"workspaces/{workspace}/datastores/",
data=payload.json(),
data=payload.model_dump_json(),
headers=self.head,
)
results = self.response_recognise(responses.status_code)
Expand All @@ -230,7 +230,7 @@ async def get_allstyles(self) -> AllStylesModel:
Client = self.http_client
responses = await Client.get(f"styles")
if responses.status_code == 200:
return AllStylesModel.parse_obj(responses.json())
return AllStylesModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -240,7 +240,7 @@ async def get_style(self, style: str) -> StyleModel:
Client = self.http_client
responses = await Client.get(f"styles/{style}.json")
if responses.status_code == 200:
return StyleModel.parse_obj(responses.json())
return StyleModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand Down Expand Up @@ -292,7 +292,7 @@ async def get_all_layers(
else:
responses = await Client.get(f"layers")
if responses.status_code == 200:
return LayersModel.parse_obj(responses.json())
return LayersModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -304,7 +304,7 @@ async def get_layer(
Client = self.http_client
responses = await Client.get(f"layers/{workspace}:{layer}")
if responses.status_code == 200:
return LayerModel.parse_obj(responses.json())
return LayerModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand Down
28 changes: 14 additions & 14 deletions src/geoserverx/_sync/gsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def response_recognise(self, r) -> GSResponse:
resp = GSResponseEnum._409.value
elif r == 200:
resp = GSResponseEnum._200.value
return GSResponse.parse_obj(resp)
return GSResponse.model_validate(resp)

def exception_handler(func):
def inner_function(*args, **kwargs):
Expand All @@ -112,7 +112,7 @@ def get_all_workspaces(self) -> Union[WorkspacesModel, GSResponse]:
Client = self.http_client
responses = Client.get(f"workspaces")
if responses.status_code == 200:
return WorkspacesModel.parse_obj(responses.json())
return WorkspacesModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -123,7 +123,7 @@ def get_workspace(self, workspace: str) -> Union[WorkspaceModel, GSResponse]:
Client = self.http_client
responses = Client.get(f"workspaces/{workspace}")
if responses.status_code == 200:
return WorkspaceModel.parse_obj(responses.json())
return WorkspaceModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -139,7 +139,7 @@ def create_workspace(
Client = self.http_client
responses = Client.post(
f"workspaces?default={default}",
content=payload.json(),
content=payload.model_dump_json(),
headers=self.head,
)
results = self.response_recognise(responses.status_code)
Expand All @@ -151,7 +151,7 @@ def get_vector_stores_in_workspaces(self, workspace: str) -> DataStoresModel:
Client = self.http_client
responses = Client.get(f"workspaces/{workspace}/datastores")
if responses.status_code == 200:
return DataStoresModel.parse_obj(responses.json())
return DataStoresModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -162,7 +162,7 @@ def get_raster_stores_in_workspaces(self, workspace: str) -> CoveragesStoresMode
Client = self.http_client
responses = Client.get(f"workspaces/{workspace}/coveragestores")
if responses.status_code == 200:
return CoveragesStoresModel.parse_obj(responses.json())
return CoveragesStoresModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -174,7 +174,7 @@ def get_vector_store(self, workspace: str, store: str) -> DataStoreModel:
Client = self.http_client
responses = Client.get(url)
if responses.status_code == 200:
return DataStoreModel.parse_obj(responses.json())
return DataStoreModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -186,7 +186,7 @@ def get_raster_store(self, workspace: str, store: str) -> CoveragesStoreModel:
Client = self.http_client
responses = Client.get(url)
if responses.status_code == 200:
return CoveragesStoreModel.parse_obj(responses.json())
return CoveragesStoreModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -197,7 +197,7 @@ def get_allstyles(self) -> AllStylesModel:
Client = self.http_client
responses = Client.get(f"styles")
if responses.status_code == 200:
return AllStylesModel.parse_obj(responses.json())
return AllStylesModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -208,7 +208,7 @@ def get_style(self, style: str) -> StyleModel:
Client = self.http_client
responses = Client.get(f"styles/{style}.json")
if responses.status_code == 200:
return StyleModel.parse_obj(responses.json())
return StyleModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand Down Expand Up @@ -254,13 +254,13 @@ def create_pg_store(
user=username,
passwd=password,
dbtype="postgis",
).dict(exclude_none=True),
).model_dump(exclude_none=True),
)
)
Client = self.http_client
responses = Client.post(
f"workspaces/{workspace}/datastores/",
data=payload.json(),
data=payload.model_dump_json(),
headers=self.head,
)
results = self.response_recognise(responses.status_code)
Expand All @@ -277,7 +277,7 @@ def get_all_layers(
else:
responses = Client.get(f"layers")
if responses.status_code == 200:
return LayersModel.parse_obj(responses.json())
return LayersModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand All @@ -288,7 +288,7 @@ def get_layer(self, workspace: str, layer: str) -> Union[LayerModel, GSResponse]
Client = self.http_client
responses = Client.get(f"layers/{workspace}:{layer}")
if responses.status_code == 200:
return LayerModel.parse_obj(responses.json())
return LayerModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
Expand Down
5 changes: 2 additions & 3 deletions src/geoserverx/models/data_store.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import List, Literal, Optional, Union
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, ConfigDict

from .workspace import WorkspaceInBulk

Expand All @@ -21,8 +21,7 @@ class DatastoreConnection(BaseModel):
key: str = Field(..., alias="@key")
path: str = Field(..., alias="$")

class Config:
allow_population_by_field_name = True
model_config = ConfigDict(populate_by_name=True)


class EntryItem(BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions src/geoserverx/models/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class DefaultStyleOfLayer(BaseModel):


class ExtraStyles(BaseModel):
_class: str = Field(..., alias="@class")
class_field: str = Field(..., alias="@class")
style: List[DefaultStyleOfLayer]


class LayerResource(BaseModel):
_class: str = Field(..., alias="@class")
class_field: str = Field(..., alias="@class")
name: str = ...
href: str = ...

Expand Down
3 changes: 1 addition & 2 deletions src/geoserverx/utils/services/async_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ async def addFile(
layer_payload,
store_header,
layer_header,
):
...
): ...


class CreateFileStore:
Expand Down
3 changes: 1 addition & 2 deletions src/geoserverx/utils/services/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def addFile(
layer_payload,
store_header,
layer_header,
):
...
): ...


class CreateFileStore:
Expand Down
Loading

0 comments on commit 9538836

Please sign in to comment.