Skip to content

Commit 1258dc0

Browse files
♻️ update methods
1 parent 82fe3f2 commit 1258dc0

File tree

3 files changed

+83
-3
lines changed

3 files changed

+83
-3
lines changed

squarecloud/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,9 @@ async def all_backups(self):
657657
async def move_file(self, origin: str, dest: str):
658658
return await self.client.move_app_file(self.id, origin, dest)
659659

660+
async def current_integration(self):
661+
return await self.client.current_app_integration(self.id)
662+
660663
@_notify_listener(Endpoint.dns_records())
661664
async def dns_records(self) -> list[DNSRecord]:
662665
return await self.client.dns_records(self.id)

squarecloud/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ async def domain_analytics(
739739
response: Response = await self._http.domain_analytics(
740740
app_id=app_id,
741741
)
742+
742743
return DomainAnalytics(**response.response)
743744

744745
@_notify_listener(Endpoint.all_backups())
@@ -772,3 +773,10 @@ async def move_app_file(
772773
async def dns_records(self, app_id: str) -> list[DNSRecord]:
773774
response: Response = await self._http.dns_records(app_id)
774775
return [DNSRecord(**data) for data in response.response]
776+
777+
@_notify_listener(Endpoint.current_integration())
778+
async def current_app_integration(self, app_id: str) -> str | None:
779+
response: Response = await self._http.get_app_current_integration(
780+
app_id
781+
)
782+
return response.response['webhook']

squarecloud/http/http_client.py

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,11 @@ async def file_delete(self, app_id: str, path: str) -> Response:
528528
code is 429
529529
"""
530530
route: Router = Router(
531-
Endpoint.files_delete(), app_id=app_id, path=path
531+
Endpoint.files_delete(),
532+
app_id=app_id,
532533
)
533-
response: Response = await self.request(route)
534+
body = {'path': path}
535+
response: Response = await self.request(route, json=body)
534536
return response
535537

536538
async def get_app_data(self, app_id: str) -> Response:
@@ -635,6 +637,7 @@ async def domain_analytics(self, app_id: str) -> Response:
635637
636638
:param app_id: The application id
637639
:return: A Response object
640+
:rtype: Response
638641
639642
:raises NotFoundError: Raised when the request status code is 404
640643
:raises BadRequestError: Raised when the request status code is 400
@@ -650,28 +653,94 @@ async def domain_analytics(self, app_id: str) -> Response:
650653
async def get_all_app_backups(self, app_id: str) -> Response:
651654
"""
652655
Returns a list of all backups of the specified application
653-
:return:
656+
657+
:return: A Response object
658+
:rtype: Response
659+
660+
:raises NotFoundError: Raised when the request status code is 404
661+
:raises BadRequestError: Raised when the request status code is 400
662+
:raises AuthenticationFailure: Raised when the request status
663+
code is 401
664+
:raises TooManyRequestsError: Raised when the request status
665+
code is 429
654666
"""
655667
route: Router = Router(Endpoint.all_backups(), app_id=app_id)
656668
response: Response = await self.request(route)
657669
return response
658670

659671
async def all_apps_status(self) -> Response:
672+
"""
673+
Returns all applications status
674+
675+
:return: A Response object
676+
:rtype: Response
677+
678+
:raises NotFoundError: Raised when the request status code is 404
679+
:raises BadRequestError: Raised when the request status code is 400
680+
:raises AuthenticationFailure: Raised when the request status
681+
code is 401
682+
:raises TooManyRequestsError: Raised when the request status
683+
code is 429
684+
"""
660685
route: Router = Router(Endpoint.all_apps_status())
661686
response: Response = await self.request(route)
662687
return response
663688

664689
async def move_app_file(self, app_id: str, origin: str, dest: str):
690+
"""
691+
Make a http request to move an app file.
692+
693+
:return: A Response object
694+
:rtype: Response
695+
696+
:raises NotFoundError: Raised when the request status code is 404
697+
:raises BadRequestError: Raised when the request status code is 400
698+
:raises AuthenticationFailure: Raised when the request status
699+
code is 401
700+
:raises TooManyRequestsError: Raised when the request status
701+
code is 429
702+
"""
665703
route: Router = Router(Endpoint.move_file(), app_id=app_id)
666704
body = {'path': origin, 'to': dest}
667705
response: Response = await self.request(route, json=body)
668706
return response
669707

670708
async def dns_records(self, app_id: str) -> Response:
709+
"""
710+
Returns dns information of the specified application
711+
712+
:return: A Response object
713+
:rtype: Response
714+
715+
:raises NotFoundError: Raised when the request status code is 404
716+
:raises BadRequestError: Raised when the request status code is 400
717+
:raises AuthenticationFailure: Raised when the request status
718+
code is 401
719+
:raises TooManyRequestsError: Raised when the request status
720+
code is 429
721+
"""
671722
route: Router = Router(Endpoint.dns_records(), app_id=app_id)
672723
response: Response = await self.request(route)
673724
return response
674725

726+
async def get_app_current_integration(self, app_id: str) -> Response:
727+
"""
728+
Returns the webhook url of the application current integration
729+
730+
:return: A Response object
731+
:rtype: Response
732+
733+
:raises NotFoundError: Raised when the request status code is 404
734+
:raises BadRequestError: Raised when the request status code is 400
735+
:raises AuthenticationFailure: Raised when the request status
736+
code is 401
737+
:raises TooManyRequestsError: Raised when the request status
738+
code is 429
739+
"""
740+
route: Router = Router(Endpoint.current_integration(), app_id=app_id)
741+
response: Response = await self.request(route)
742+
return response
743+
675744
@property
676745
def last_response(self) -> Response | None:
677746
"""

0 commit comments

Comments
 (0)