Skip to content

Commit

Permalink
fixed responses ro response for singular operations
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnaglodha committed Nov 19, 2024
1 parent 568ba01 commit 9c766c0
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 86 deletions.
64 changes: 32 additions & 32 deletions src/geoserverx/_async/gsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ async def get_all_workspaces(self) -> Union[WorkspacesModel, GSResponse]:
# Get specific workspaces
async def get_workspace(self, workspace: str) -> Union[WorkspaceModel, GSResponse]:
Client = self.http_client
responses = await Client.get(f"workspaces/{workspace}")
if responses.status_code == 200:
return WorkspaceModel.model_validate(responses.json())
response = await Client.get(f"workspaces/{workspace}")
if response.status_code == 200:
return WorkspaceModel.model_validate(response.json())
else:
results = self.response_recognise(responses.status_code)
results = self.response_recognise(response.status_code)
return results

# Create workspace
Expand All @@ -150,12 +150,12 @@ async def create_workspace(
payload: NewWorkspace = NewWorkspace(
workspace=NewWorkspaceInfo(name=name, isolated=Isolated)
)
responses = await Client.post(
response = await Client.post(
f"workspaces?default={default}",
data=payload.model_dump_json(),
headers=self.headers,
)
results = self.response_recognise(responses.status_code)
results = self.response_recognise(response.status_code)
return results

# Get vector stores in specific workspaces
Expand Down Expand Up @@ -184,22 +184,22 @@ async def get_raster_stores_in_workspaces(
async def get_vector_store(self, workspace: str, store: str) -> DataStoreModel:
url = f"workspaces/{workspace}/datastores/{store}.json"
Client = self.http_client
responses = await Client.get(url)
if responses.status_code == 200:
return DataStoreModel.model_validate(responses.json())
response = await Client.get(url)
if response.status_code == 200:
return DataStoreModel.model_validate(response.json())
else:
results = self.response_recognise(responses.status_code)
results = self.response_recognise(response.status_code)
return results

# Get raster store information in specific workspaces
async def get_raster_store(self, workspace: str, store: str) -> CoveragesStoreModel:
url = f"workspaces/{workspace}/coveragestores/{store}.json"
Client = self.http_client
responses = await Client.get(url)
if responses.status_code == 200:
return CoveragesStoreModel.model_validate(responses.json())
response = await Client.get(url)
if response.status_code == 200:
return CoveragesStoreModel.model_validate(response.json())
else:
results = self.response_recognise(responses.status_code)
results = self.response_recognise(response.status_code)
return results

# Get all styles in GS
Expand All @@ -215,11 +215,11 @@ async def get_all_styles(self) -> AllStylesModel:
# Get specific style in GS
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.model_validate(responses.json())
response = await Client.get(f"styles/{style}.json")
if response.status_code == 200:
return StyleModel.model_validate(response.json())
else:
results = self.response_recognise(responses.status_code)
results = self.response_recognise(response.status_code)
return results

# Add postgres db
Expand Down Expand Up @@ -247,12 +247,12 @@ async def create_pg_store(
)
)
Client = self.http_client
responses = await Client.post(
response = await Client.post(
f"workspaces/{workspace}/datastores/",
data=payload.model_dump_json(),
headers=self.headers,
)
results = self.response_recognise(responses.status_code)
results = self.response_recognise(response.status_code)
return results

async def create_file_store(self, workspace: str, store: str, file, service_type):
Expand Down Expand Up @@ -312,18 +312,18 @@ async def get_layer(
self, workspace: str, layer: str
) -> Union[LayerModel, GSResponse]:
Client = self.http_client
responses = await Client.get(f"layers/{workspace}:{layer}")
if responses.status_code == 200:
return LayerModel.model_validate(responses.json())
response = await Client.get(f"layers/{workspace}:{layer}")
if response.status_code == 200:
return LayerModel.model_validate(response.json())
else:
results = self.response_recognise(responses.status_code)
results = self.response_recognise(response.status_code)
return results

# Delete specific layer
async def delete_layer(self, workspace: str, layer: str) -> GSResponse:
Client = self.http_client
responses = await Client.delete(f"layers/{workspace}:{layer}")
results = self.response_recognise(responses.status_code)
response = await Client.delete(f"layers/{workspace}:{layer}")
results = self.response_recognise(response.status_code)
return results

# Get all layer groups
Expand Down Expand Up @@ -366,13 +366,13 @@ async def get_geofence_rule(self, id: int) -> Union[Rule, GSResponse]:
# If the module check fails, return the GSResponse directly
if isinstance(module_check, GSResponse):
return module_check
responses = await Client.get(
response = await Client.get(
f"geofence/rules/id/{id}", headers={"Accept": "application/json"}
)
if responses.status_code == 200:
return Rule.model_validate(responses.json())
if response.status_code == 200:
return Rule.model_validate(response.json())
else:
results = self.response_recognise(responses.status_code)
results = self.response_recognise(response.status_code)
return results

# Create geofence on geoserver
Expand All @@ -384,10 +384,10 @@ async def create_geofence(self, rule: Rule) -> GSResponse:
if isinstance(module_check, GSResponse):
return module_check
Client = self.http_client
responses = await Client.post(
response = await Client.post(
"geofence/rules",
content=PostingRule.model_dump_json(),
headers=self.headers,
)
results = self.response_recognise(responses.status_code)
results = self.response_recognise(response.status_code)
return results
Loading

0 comments on commit 9c766c0

Please sign in to comment.