Skip to content

Commit

Permalink
chore: fixed some deprecations
Browse files Browse the repository at this point in the history
For #196
  • Loading branch information
tstorek committed Jul 17, 2023
1 parent 2d87ca0 commit 6e127d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions filip/clients/base_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self,
def __enter__(self):
if not self.session:
self.session = requests.Session()
self.headers.update(self.fiware_headers.dict(by_alias=True))
self.headers.update(self.fiware_headers.model_dump(by_alias=True))
self._external_session = False
return self

Expand Down Expand Up @@ -94,12 +94,12 @@ def fiware_headers(self, headers: Union[Dict, FiwareHeader]) -> None:
if isinstance(headers, FiwareHeader):
self._fiware_headers = headers
elif isinstance(headers, dict):
self._fiware_headers = FiwareHeader.parse_obj(headers)
self._fiware_headers = FiwareHeader.model_validate(headers)
elif isinstance(headers, str):
self._fiware_headers = FiwareHeader.parse_raw(headers)
self._fiware_headers = FiwareHeader.model_validate_json(headers)
else:
raise TypeError(f'Invalid headers! {type(headers)}')
self.headers.update(self.fiware_headers.dict(by_alias=True))
self.headers.update(self.fiware_headers.modul_dump(by_alias=True))

@property
def fiware_service(self) -> str:
Expand All @@ -121,7 +121,7 @@ def fiware_service(self, service: str) -> None:
None
"""
self._fiware_headers.service = service
self.headers.update(self.fiware_headers.dict(by_alias=True))
self.headers.update(self.fiware_headers.model_dump(by_alias=True))

@property
def fiware_service_path(self) -> str:
Expand All @@ -143,7 +143,7 @@ def fiware_service_path(self, service_path: str) -> None:
None
"""
self._fiware_headers.service_path = service_path
self.headers.update(self.fiware_headers.dict(by_alias=True))
self.headers.update(self.fiware_headers.model_dump(by_alias=True))

@property
def headers(self):
Expand Down
4 changes: 3 additions & 1 deletion filip/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class FiwareHeader(BaseModel):
Context Brokers to support hierarchical scopes:
https://fiware-orion.readthedocs.io/en/master/user/service_path/index.html
"""
model_config = ConfigDict(populate_by_name=True, validate_assignment=True)

service: str = Field(
alias="fiware-service",
default="",
Expand All @@ -84,7 +86,7 @@ class FiwareHeader(BaseModel):
max_length=51,
pattern=r'^((\/\w*)|(\/\#))*(\,((\/\w*)|(\/\#)))*$'
)
model_config = ConfigDict(populate_by_name=True, validate_assignment=True)



class FiwareRegex(str, Enum):
Expand Down

0 comments on commit 6e127d7

Please sign in to comment.